Sunday, July 28, 2013

Counting Ids
CODE

import math
while(True):
    s=raw_input()
    str=s.split(' ')
    n=int(str[0])
    r=int(str[1])
    if(n==0 & r==0):
        break;
    else:
        ans=(n*(pow(n,r)-1)/(n-1))%1000000007
        print (ans)

No comments:

Post a Comment