1633:【例 3】Sumdiv

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll M=9901;
ll a,b,ans=1,cnt;
ll p[20],c[20];
inline void divide(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            p[++cnt]=i;
            while(n%i==0) n/=i,c[cnt]++;
        }
    }
    if(n>1) p[++cnt]=n,c[cnt]=1;
    //for(int i=1;i<=cnt;i++) cout<<p[cnt]<<' '<<c[cnt]<<' ';
}
inline int power(ll x,ll y)
{
    ll res=1;
    while(y)
    {
        if(y&1) res=res*x%M;
        x=x*x%M;
        y>>=1;
    }
    return res;
}
int main()
{
    scanf("%lld%lld",&a,&b);
    divide(a);
    for(int i=1;i<=cnt;i++)
    {
        if((p[i]-1)%M==0)
        {
            ans=(b*c[i]+1)%M*ans%M;
            continue;
        }
        ll xx=power(p[i],b*c[i]+1);
        xx=(xx-1+M)%M;
        ll yy=p[i]-1;
        yy=power(yy,M-2);
        ans=ans*xx%M*yy%M;
    }
    printf("%lld\n",ans);
    return 0;
}

 

posted @ 2019-08-24 16:36  Gold_stein  阅读(283)  评论(0编辑  收藏  举报