题目
题解思路
约数定理以及题解文章
定义一个递归函数对每一个等比数列 进行 分治处理
每次 操作都一半合并 分治处理
类似二分的思想 log n
AC代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 9901 ;
long long ksm(long long a , long long b )
{
long long res = 1 ;
while( b )
{
if ( b & 1 ) res = ( res * a )% mod ;
a = (a * a ) % mod ;
b >>= 1;
}
return res ;
}
long long fenzi( long long xx , long long kk )
{
if ( kk == 1 )
return 1;
if ( kk % 2 == 0 )
return (1 + ksm(xx , kk/2))*fenzi( xx , kk / 2 ) % mod ;
return ( ksm( xx , kk -1 ) + fenzi( xx , kk -1 ) ) % mod ;
}
int main ()
{
ios::sync_with_stdio(false);
long long a , b , ans = 1 ;
cin >> a >> b;
for (long long i = 2 ; i*i <= a ; i++ )
{
if ( a % i == 0 )
{
int s = 0 ;
while( a % i == 0 )
{
a/=i;
s++;
}
ans = ( ans * fenzi( i , b*s + 1 ) ) % mod ;
}
}
if ( a > 1 )
ans = ( ans * fenzi( a , b + 1 ) ) % mod ;
if ( a == 0 )
ans = 0 ;
cout<<ans<<"\n";
return 0 ;
}