C++WA88求助

P1593 因子和

@[Pandingding](/user/722468) i-1 不一定有逆元,所以要特判 ```cpp #include<bits/stdc++.h> using namespace std; long long a,ans=1,b,cnt,i; long long pw(long long a,long long b) { long long f=a%9901,x=1,y=b; while(y) { if(y&1) x=x*f%9901; f=f*f%9901; y>>=1; } return x; } int main() { scanf("%lld%lld",&a,&b); if(!a) { printf("0"); return 0; } if(a==1||!b) { printf("1"); return 0; } for(i=2;i<=a;++i) { cnt=1; while(!(a%i)) { cnt+=b; a/=i; } if(cnt>=2) if(i%9901!=1) ans=ans*(pw(i,cnt)+9900)%9901*pw(i-1,9899)%9901; else ans=ans*cnt%9901; } printf("%lld",ans); return 0; } ```
by 5k_sync_closer @ 2023-06-29 15:32:32


@[5k_sync_closer](/user/388651) 谢谢,此帖结。
by Pandingding @ 2023-06-29 15:34:42


|