Poj 1845)

Source: Internet
Author: User
Sumdiv
Time limit:1000 ms   Memory limit:30000 K
Total submissions:13959   Accepted:3433

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 ).

Source

Romania oi 2002

Thoughts:

http://hi.baidu.com/necsinmyway/item/9f10b6d96c5068fbb2f77740

AC code:

# Include <iostream> using namespace STD; # define ll long longll pow_mod (ll a, ll N, int mod) {// fast power ll r = 1; ll base =; while (n) {If (N & 1) r = r * base % MOD; base = base * base % MOD; n >>=1;} return R % 9901 ;} ll sum (ll a, LL B, ll mod) {// returns the first n of the proportional sequence and if (B = 0) return 1; if (B % 2 = 1) Return (sum (A, B/2, MoD) * (pow_mod (A, B/2 + 1, MoD) + 1 )) % MOD; else return (sum (A, B-1, MoD) + pow_mod (a, B, MoD) % MOD;} int main () {ll A, B; ll ans; while (CIN> A> B) {ans = 1; for (ll I = 2; I * I <= A; I ++) {// split a into the product of the prime number if (a % I = 0) {ll s = 0; while (a % I = 0) {s ++; a/= I;} ans = ans * sum (I % 9901, B * s, 9901) % 9901;} if (a> = 2) {ans = ans * sum (a % 9901, B, 9901) % 9901 ;}cout <ans <Endl ;}return 0 ;}



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.