求助,1~10的点wa,其余AC

P1593 因子和

_QWQ_TAT_ @ 2024-04-13 10:32:40

rt

 #include <bits/stdc++.h>
using namespace std;
#define Xia_Qian return
#define AKIOI 0
typedef long long ll;
const int mod=9901;

ll a,b;
ll ans=1;
ll p[100005],k[100005],topp,topk;

ll qpow(ll a,ll b){
    ll ans=1;
    while (b){
        if (b&1) {
            ans=(ans*(a%mod))%mod;
        }
        b>>=1;a=(a*a)%mod;
    }
    return ans%mod;
}

int main(){
    cin>>a>>b;
    if (a==0){
        puts("0");
        Xia_Qian AKIOI;
    }if (b==0){
        puts("1");
        Xia_Qian AKIOI;
    }   //puts("!");
    ll x=a;
    for (int i=2;i*i<=a;i++){
        if (x%i==0){
            p[++topp]=i;
            while(x%i==0){
                k[topp]++;
                x/=i;
            }
            k[i]*=b;
        }
    }
    if (x>1){
        p[++topp]=x;
        k[topp]+=b;
//      cout<<k[topp]<<" ";
    }
    for (int i=1;i<=topp;i++){
        if (p[i]%mod==1){
            ans=ans*(k[i]+1)%mod;
        }else{
            ll x=(qpow(p[i],k[i]+1)-1+mod)%mod;
            ll y=qpow(p[i]-1,mod-2);
            ans=ans*x%mod*y%mod;        
        }

    }
    cout<<(ans+mod)%mod;
    Xia_Qian AKIOI;
}

by _QWQ_TAT_ @ 2024-04-13 11:14:58

你说得对,但我之前试过这个数据,输出为1,你可以自己试一下 @yjz468


by _QWQ_TAT_ @ 2024-04-13 11:35:36

ok,我自己调过了


|