<span id="Label3"></p><p class="pst"><p class="pst">Description</p></p>Consider 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).<br><br>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.<p class="pst"><p class="pst">Input</p></p>The input consists of several test cases. Each test case is contains a line with the integer x (1 <= x <= 10000000).<br><br>A test Case of X = 0 indicates the end of input, and should not being processed.<p class="pst"><p class="pst">Output</p></p>For each test case, in a separate line, please output the result of S modulo 29.<p class="pst"><p class="pst">Sample Input</p></p>1100000<p class="pst"><p class="pst">Sample Output</p></p>610<pre><pre><br><br>The factor of a number and is an integrable function</pre></pre><p><p>About the integrable function, i.e. F (ab) =f (a) *f (b), There are many integrable functions in number theory</p></p><p><p>To prove it:</p></p><p><p>S (x) represents the factor of X and.</p></p><p><p>If x can be divided into a, b (which must be a prime number), then S (x) =s (a) *s (b).</p></p><p><p>Why must be divided into prime, because a prime factor after 1 and its own, for a, b, is 1,a,1,b, then x=a*b,x factor only 1,a,,b,x these four numbers,</p></p><p><p>(1+a) * (1+b) =1+a+b+a*b. see, This is called a number factor and is an integrable function.</p></p><p><p></p></p><p><p><strong>(a*b)/c%m= a%m * b%m * INV (c)<br></strong>Where INV (c) satisfies the smallest integer (C*INV (c))%m=1</p></p><p><p></p></p><p><p>a^ (b)%c----->a (b%k (c) +k (c))%c (b>=k (c)) where K (c) is the Euler value of C.</p></p><pre class="brush:cpp;gutter:true;"><pre class="brush:cpp;gutter:true;">#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath >using namespace Std;typedef Long LL; ll Qpow (int X,int y) { ll b = 1; For (; y;y>>=1) { if (y&1) b = (b*x)%29; x= (x*x)%29; } b--; Return b<0?b+29:b;} int main () { int x; While (~scanf ("%d", &x) &&x) { LL a = 2*x+1;if (a>28) a%=28,a+=28; LL B = x+1;if (b>28) b%=28,b+=28; printf ("%d\n", qpow (2,a) *qpow (3,b) *qpow (22,b) *9%29); } Return 0;}</pre></pre><p><p> </p></p><p><p>HDU 1452 Fzu 1053 Happy 2004 (inverse function + Factor and function + large exponent modulus simplification formula)</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.