输入a和b,求a^b的所有因子之和。
#include <iostream> #define ll long long using namespace std; const int mod=9901; ll a,b; int quick(ll a,ll b,ll m) { ll res,t; res=1; t=a%m; while(b){ if(b&1){ res=res*t%m; } t=t*t%m; b>>=1; } return res; } int main() { ios::sync_with_stdio(false);cin.tie(0); cin>>a>>b; if(b==0||a<=1) {cout<<"1"<<endl;return 0;} ll ans=1; int s; for(int i=2;i*i<=a;i++){ s=0; while(a%i==0){ a/=i; s++; } if((i-1)%mod==0)ans=ans*(quick(i,s*b+1,mod*(i-1))-1)/(i-1)%mod; else ans=ans*(quick(i,s*b+1,mod)-1)*quick(i-1,mod-2,mod)%mod; } if(a>1){ if((a-1)%mod==0)ans=ans*(quick(a,b+1,mod*(a-1))-1)/(a-1)%mod; else ans=ans*(quick(a,b+1,mod)-1)*quick(a-1,mod-2,mod)%mod; } cout<<(ans+mod)%mod<<endl; return 0; }