等比数列那里忘判项数等于 $1$ 的情况了.
Code:
#include <cstdio> #include <vector> #include <algorithm> #define mod 9901 #define N 50000002 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespace std; ll qpow(ll base,ll k) { ll tmp=1; for(;k;base=base*base%mod,k>>=1)if(k&1) tmp=tmp*base%mod; return tmp; } ll inv(ll k) { return qpow(k,mod-2); } ll calc(ll a,ll b,ll k) { if(b==1) return a; return (qpow(b,k+1)-1+mod)%mod*inv(b-1)%mod; } struct Node { int prime,p; Node(int prime=0,int p=0):prime(prime),p(p){} }; vector<Node>v; int tot; bool vis[N]; int prime[4000000]; void init() { int i,j; for(i=2;i<N;++i) { if(!vis[i]) prime[++tot]=i; for(j=1;j<=tot&&i*prime[j]<N;++j) { vis[i*prime[j]]=1; if(i%prime[j]==0) break; } } } int main() { init(); // setIO("input"); int i,j,AA,B,h; scanf("%d%d",&AA,&B),h=AA; for(i=1;i<=tot;++i) if(h%prime[i]==0) { int cc=0; for(;h%prime[i]==0;h/=prime[i]) ++cc; v.push_back(Node(prime[i],cc)); } ll re=1; for(i=0;i<v.size();++i) { int p=v[i].p; ll tmp=0,A=1; for(j=1;j<=p;++j) A=A*v[i].prime%mod,tmp=(tmp+A)%mod; tmp=tmp*calc(1,A,B-1)%mod; re=re*(tmp+1)%mod; } printf("%lld ",re); return 0; }