Happy 2004
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
problem DescriptionConsider a positive integer x,and let S is the sum of all positive integer divisors of 2004^x. Your job is to determine s modulo (the rest of the division of S by 29).
Take X = 1 for an example. The positive integer divisors of 2004^1 are 1, 2, 3, 4, 6,, 167, 334, 501, 668, 1002 and 2004. Therefore s = 4704 and s modulo are equal to 6.InputThe input consists of several test cases. Each test case is contains a line with the integer x (1 <= x <= 10000000).
A test Case of X = 0 indicates the end of input, and should not being processed.OutputFor each test case, in a separate line, please output the result of S modulo 29.Sample Input1100000Sample Output610 Source ACM Summer Training Team Practice Competition (VI)recommendLCY | We have carefully selected several similar problems for you:1695 1573 1788 1060 1370 first First 2004 = 2*2*3*167 then, using factors and the nature of the integrable function ( Konjac Konjac prepared to write a continuous update on the integrable function proof and learning article): Σ (2004^x) =σ (2^2x) *σ (3^x) *σ (167^x) Mod 29∵167≡22 (Mod29) so σ (2004^x) =σ (2^2x) *σ (3^x ) *σ (22^x) Mod = [2^ (2x+1) -1][3^ (x+1) -1]/2*[22^ (x+1) -1]/21 because the modulo 29 multiplication inverse of 2 is 15, 22 modulo 29 multiplication inverse is 18 so σ (2004^x) = [2^ (2x+1) -1][3^ (x+1) -1]*15*[22^ (x+1) -1]*18 is available fast power solution
1#include <Set>2#include <queue>3#include <vector>4#include <cstdio>5#include <cstdlib>6#include <cstring>7#include <iostream>8#include <algorithm>9 using namespacestd;Ten Const intMod = in; One #defineREP (i,n) for (int i=1;i<=n;i++) A #definefor (I,L,R) for (int i=l;i<=r;i++) - - intans,x; the - intQuickpow (intMintN) { - intans=1; - while(n) { + if(n&1) ans= (ans*m)%Mod; -m= (m*m)%Mod; +n>>=1; A } at returnans%Mod; - } - - intMain () { - while(SCANF ("%d",&x), x) { - intans=0; inAns= (Quickpow (2,2*x+1)-1)%Mod; -ans=ans%mod* (Quickpow (3, x+1)-1)* the%Mod; toans=ans%mod* (Quickpow ( A, x+1)-1)* -%Mod; +printf"%d\n", ans%Mod); - } the return 0; *}View Code
HDU1452 Happy 2004 (Factor and)