ZSUM - Just Add It
For two given integers n and k find (Zn+Zn-1-2Zn-2)mod 10000007 , where Zn=Sn+Pn and Sn=1k+2k+3k+…..+nk and Pn=11+22+33+……+nn.
There are several test cases [ ≤10000 ].In each case two space separated positive integers n and k are given.
For last test case n and k are given as 0 0 ,which is not to be processed.
1<n<200000000 , 0<k<1000000.
For each case print the asked value in separate line.
Input: 10 3
|Added by:||Manohar Singh|
|Cluster:||Cube (Intel Pentium G860 3GHz)|
|Languages:||All except: SCM chicken|
Modular exponentiation'll help a lot...:)Last edit: 2015-06-29 11:17:04
Thanks @ deadbrain
Python coders please do not attempt the problem, it will be a total waste of time as will always get a TLE
Modular exponentiation would help
thanks @ deadbrain
for those who don't know how to solve the problem efficiently, read Modular exponentiation wiki article first... Lot to learn from this question.