Number of about 5845 A ^ and B

 

description

 

Given two positive integers A and B (0 <= A, B <* = 10. 5 . 7 ), find A B all about the number of and, as a result may be large, as long as you will result modulo 9901 to .

Entry

 

Two positive integers A and B (0 <= A, B <* = 10. 5 . 7 )

Export

 

A B  about their sum mod 9901.

Sample input

 

2 3 

 

Sample Output

 

15

Source

Code Record

#include<bits/stdc++.h>
using namespace std;
const int N=1e4;
const int mod=9901;
typedef long long ll;
int a,b;
ll num[N],siz[N];
ll power(ll x,ll y)
{
      ll ans=1;
      while(y>0)
      {
          if(y%2)ans=(ans*x)%mod;
          y/=2;
          x=x*x%mod;
      }
      return ans;
}//快速幂
ll sum(ll x,ll y)
{
    if(y==0)return 1;
    if(y%2)return  (sum(x,y/2)*(1+power(x,y/2+1)))%mod;
    return  (sum(x,y/2-1)*(1+power(x,y/2+1))+power(x,y/2))%mod;
}
int main()
{
      cin>>a>>b;
      int I = 2 , K = 0 , ANS = . 1 ;
       the while (I * I <= A) 
      { 
          IF (A% I == 0 ) 
          { 
              NUM [K] = I;
               the while (I% A == 0 ) 
              { 
                  SIZ [k] ++; // record the number of k-factors 
                  a / = I; 
              } 
              k ++ ; 
          } 
          I == 2 I ++: = I +? 2 ; // ignore even number other than 2.
      }
       IF (! A = . 1 ) NUM [K] = a, SIZ [K ++] = . 1 ;
       // above to find a all factors 
      for ( int I = 0 ; I <K; I ++ ) 
      { 
          ANS = (ANS * (SUM ([I] NUM, SIZ [I] * B)% MOD))% MOD; 
      } 
      COUT << ANS << endl; 
}
View Code

 

Guess you like

Origin www.cnblogs.com/llhsbg/p/11374720.html