Topic links
HDU 1425 Happy 2004
Exercises
Main topic:
Please
\[\sum_{d|2004^{x}}d\ mod\ 29\]
Recorded as \ (s (2004^x) \)
\ (sum (2004^{x}) = S (2^2x)) * S (3^x) * s (167^x) \)
$167?mod?29 = 22 $
\ (S (2004^x) = S (2^{2x}) * S (3^{x})) * s (22^x) \)
At this point the base becomes prime
If P is a prime number
\ (S (p^n) =1+p+p^2+...+p^n= (p^{n+1}-1)/(P-1) (1) \)
The above formula is taken down and the code is written.
For division take mod requires inverse
29 for prime number--fast power
Or maybe it's better to make a watch. 233
Code
#include <cmath>#include <cstdio>#include <algorithm>inline intRead () {intx=0, f=1;CharC=getchar (); while(c<' 0 '|| C>' 9 ') C=getchar (); while(c<=' 9 '&&c>=' 0 ') x=x*Ten+c-' 0 ', C=getchar ();returnx;}#define MODintX,a,b,c;intPowintAintP) {intret=1; for(;p; p>>=1, A=a*a%mod) {if(p&1) Ret=ret*a%mod; }returnRET;}intMain () { while(1) {x=read ();if(!x) Break; A=pow (2,2*x+1); B=pow (3X+1); C=pow ( AX+1); printf"%d\n", (A-1) * (b-1)* the* (c-1)* -%MOD); }return 0;}
HDU 1425 Happy 2004