- #1
- 7
- 0
Hi, I wonder that is there any way to disassemble this operation ((n+2^(n-2))^2 mod 1000000007) without counting 2^n-2. Please, help me.
"mod_pow" is a function (using fast modular exponentiation) which returns the result of exponentiation modulo 1000000007 - mod_pow (the first parameter, second parameter, modulo). The first parameter is the base, and the second parameter is the exponent.
For:
y <- n + mod_pow (2, n-2, 1000000007).
result <- mod_pow (y, 2, 1000000007).
I get an incorrect result, so I had misunderstood something. Very please to explain.
Evaluations of (n + 2^(n-2))^2 mod 1000000007, for n = ...
2: 9 9 9
3: 25 25 25
4: 64 64 64
10: 70756 70756 70756
20: 729962420 729962420 729962420
456: 781936176 781936176 781936176
456000: 832296930 832296930 832296930
4560000: 786542175 786542175 786542175
45600000: 98463981 98463981 98463981
456000000: 494805060 494805060 494805060
500000005: 250000008 250000008 250000008
1000000008: 4 4 4
Here are the calculations that should be correct: http://img695.imageshack.us/img695/3950/calcw.png [Broken]
My program returns the same result (the first based on a string and second without them). I also have exactly the same results as you. The problem is probably in the wrong set formula :/ I see no other option :/
Thank you very much for your help which was given to me here ;)
I send the source code for online judge, that evaluates the results, but the score for my program is "Wrong answer".