whileAK @ 2023-07-25 19:07:32
刚刚学逆元的蒟蒻~WA了前十个点(悲)或者谁能给个#1的数据也行
#include<bits/stdc++.h>
using namespace std;
long long a,b,p[10010],c[10010]={},m=0,mod=9901,up,down,sum=1;
void break_out_a(){
for(long long i(2);i*i<=a;++i){
if(a%i==0)p[++m]=i;
while(a%i==0)a/=i,++c[m];
}
if(a>1)p[++m]=a,c[m]=1;
}
long long quick_mi(long long t,long long n){//t^n
long long ans=1;
for(;n;n>>=1){
if(n&1)ans=ans*t%mod;
t=t*t%mod;
}
return ans;
}
int main(){
scanf("%lld%lld",&a,&b);
if(a==0){
printf("0\n");
return 0;
}
break_out_a();
for(long long i(1);i<=m;++i){
c[i]=(c[i]*b+1)%mod;
if((p[i]-1)%mod==0){
sum=c[i]*sum%mod;
continue;
}
up=quick_mi(p[i],c[i]);
up=(up-1+mod)%mod;
down=quick_mi(p[i]-1,mod-2);
sum=sum*up%mod*down%mod;
}
printf("%lld",(sum%mod+mod)%mod);
return 0;
}```
by whileAK @ 2023-07-26 11:58:53
咳有大佬私信我了我c[i]=(c[i]*b+1)%mod;把%mod去掉就AC了~所以说幂是不能取模的~此贴结
by Rikka_lyly @ 2023-10-24 16:53:27
感谢,原来还有这种事情