Sunday, July 28, 2013

15388 Easy One For Cartman

Easy One For Cartman

CODE
import math
t=input()
for i in range(t):
    s=raw_input()
    str=s.split(' ')
    a=int(str[0])
    b=int(str[1])
    n=int(str[2])
    d=b-a
    ans=n*(2*a+(n-1)*d)/2
    #ans=(pow(n%1000000007,r%1000000007))%1000000007
    print ans

No comments:

Post a Comment