Sumdiv
Description
Consider two natural numbers a and B. Let s be the sum of all natural divisors of a ^ B. Determine s modulo 9901 (the rest of the division of S by 9901 ).
Input
The only line contains the two natural numbers A and B, (0 <= A, B <= 50000000) separated by blanks.
Output
The only line of the output will contain in S modulo 9901.
Sample Input
2 3
Sample output
15
Hint
2 ^ 3 = 8.
The natural divisors of 8 are: 1, 2, 4, 8. Their sum is 15.
15 modulo 9901 is 15 (that shoshould be output ).
Use a lot of knowledge points from this click to open the link
The AC code is as follows:
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # define mod 9901 # define M 10000 # define ll long longusing namespace STD; ll power (ll d, ll p) // Power Optimization {ll ans = 1; while (P> 0) {If (P % 2) ans = (ANS * D) % MOD; P/= 2; D = (D * D) % MOD;} return ans;} ll sum (ll d, ll p) // sum recursion of proportional series {If (P = 0) return 1; if (P = 1) return 1 + D; If (P % 2 = 1) return sum (d, p/2) * (1 + power (d, p/2 + 1) % MOD; else return (sum (d, p/2-1) * (1 + Power (d, p/2) % mod + power (d, p) % MOD;} int main () {int I, j; int A, B; while (~ Scanf ("% d", & A, & B) {int DS [m]; int po [m]; int TT = 0; for (I = 2; I * I <= A;) // calculate the factor of a {if (a % I = 0) {DS [TT] = I; po [TT] = 0; while (! (A % I) {po [TT] ++; A/= I;} TT ++;} I = 2? I ++: I + = 2;} if (! = 1) {DS [TT] = A; po [TT ++] = 1;} ll ans = 1; for (I = 0; I <tt; I ++) ans = (ANS * (LL) sum (DS [I], po [I] * B) % MOD; printf ("% i64d \ n", ANS );}}
Poj 1845 sumdiv