34分求助!!!

P1593 因子和

wuxiyi @ 2022-12-10 17:28:48

#include<iostream>
using namespace std;
long long n[10010][3]={0},cnt,ans=1,a,b;
void fenjie()
{
    for (long long i=2;i*i<=a;i++)
    {
        if (a%i==0)
        {
            cnt++;
            n[cnt][1]=i;
            n[cnt][2]=1;
            a/=i;
            while (a%i==0)
            {
                a/=i;
                n[cnt][2]++;
            }
        }
    }
    if (a>1)
    {
        cnt++;
        n[cnt][1]=a;
        n[cnt][2]=1;
    }
    for(long long i=1;i<=cnt;i++) 
    {
        n[i][2]*=b;
    }
}
long long qpow(long long a,long long b)
{
    long long ans=1;
    while (b>0)
    {
        if (b%2==1)
        {
            ans=(ans%9901)*(a%9901)%9901;
        }
        a=a*a%9901;
        b/=2;
    }
    return ans%9901;
}
long long sum(long long p,long long c)
{
    if (c==0)
    {
        return 1;
    }
    if (c%2==1)
    {
        return ((1+qpow(p,(c+1)/2))*sum(p,(c-1)/2))%9901;
    }
    else if (c%2==0)
    {
        return ((1+qpow(p,c/2))*sum(p,c/2)+qpow(p,c))%9901;
    }
}
int main()
{
    cin>>a>>b;
    if (a==0)
    {
        cout<<0;
        return 0;
    }
    fenjie();
    for (int i=1;i<=cnt;i++)
    {
        ans*=sum(n[i][1],n[i][2])%9901;
        ans%=9901;
    }
    cout<<ans;
    return 0;
}

???


by wuxiyi @ 2022-12-10 17:29:37

WA #1 2 3 4 5 6 7 8 9 10 13


by ryl_ahu @ 2023-05-09 20:23:17

这位同学,我和你你一样都是34分(蒟蒻),你猜猜这题为啥是绿色的?肯定要用高精度(虽然我也不会...)


|