poj1845

maksyuki 发表于 oj 分类,标签: , ,
0

Sumdiv

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 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 should be output).

Source

Romania OI 2002

 

题目类型:素因子分解+逆元+整数快速幂取模

算法分析:首先使用Euler筛将素数预打表,然后从小到大判断每个素数在a中出现的指数值,然后带入约数和公式边模边求解,这里使用了一个求逆元非常好的公式:a / b mod (p) = a mod (mb) / m,由于指数比较大,所以要使用整数快速幂来加速运算