longlongpower1(longlong base,longlong power,longlong mod){longlong result =1;for(int i=1;i<=power;i++)
result =((result%mod)*(base%mod))%mod;return result;}
4.2 快速幂
310=3×3×3×3×3×3×3×3×3×3
310=(3×3)×(3×3)×(3×3)×(3×3)×(3×3)
310=(3×3)5
310=95
95=94×91
95=812×91
95=56611×91
longlongpower2(longlong base,longlong power,longlong mod){longlong result =1;while(power>0){if(power%2==0){
power = power/2;
base =((base%mod)*(base%mod))%mod;}else{
power = power -1;
result =((result%mod)*(base%mod))%mod;
power = power/2;
base =((base%mod)*(base%mod))%mod;}}return result;}
longlongpower3(longlong base,longlong power,longlong mod){longlong result =1;while(power>0){if(power%2==1){
result =((result%mod)*(base%mod))%mod;}
power = power/2;
base =((base%mod)*(base%mod))%mod;}return result;}
longlongpower4(longlong base,longlong power,longlong mod){longlong result =1;while(power>0){if(power&1){
result =((result%mod)*(base%mod))%mod;}
power >>=1;
base =((base%mod)*(base%mod))%mod;}return result;}
#include<iostream>#include"power4.h"usingnamespace std;longlongsum(longlong a,longlong n,longlong mod){if(n ==1)return a;longlong t =sum(a,n/2,mod);if(n&1){longlong cur =power4(a,n/2+1,mod);
t =(t+t*cur%mod)%mod;
t =(t+cur)%mod;}else{longlong cur =power4(a,n/2,mod);
t=(t+t*cur%mod)% mod;}return t;}intmain(){
cout <<1+sum(2,3,9901);return0;}
#include<iostream>#include<cstdio>#define size 10000#define mod 9901usingnamespace std;int p[size],n[size];//快速幂 longlongpow3(longlongint a,longlongint b ){longlongint r =1, base = a;while( b !=0){if( b &1)
r =(r * base)% mod;
base =(base * base)% mod;
b >>=1;}return r;}//二分递归求解等比数列之和longlongsum(longlong p,longlong n){if(n==0)return1;if(n%2)return((sum(p,n/2)% mod)*(1+pow3(p,n/2+1))% mod )% mod;elsereturn(((sum(p,n/2-1)% mod)*(1+pow3(p,n/2+1))% mod )% mod +pow3(p,n/2)%mod)%mod;}intmain(){int A,B;scanf("%d%d",&A,&B);
int js=0;//质因数分解A,根号法和递归法for(int i=2;i*i<=A;){if(A%i==0){
p[js]=i;//质因数
n[js]=0;while(A%i==0){//质因数次数
n[js]++;
A/=i;}
js++;}if(i==2) i++;else i+=2;}//A本身就是素数的if(A!=1){
p[js]=A;
n[js++]=1;}longlong ans=1;for(int i=0;i<js;i++){
ans=( ans *sum(p[i],n[i]*B)%mod )%mod;}
cout<<ans<<endl;return0;}