littleseven @ 2019-07-24 13:07:26
大佬求教,全部RE,样例本地可以过,求原因
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define MOD 9901
#define MAX 5000100
int a,b;
int prime[MAX],num[MAX],num_cnt[MAX],vis[MAX];
ll exgcd(ll a,ll b,ll &x,ll &y)
{
if(a==0&&b==0) return -1ll;
if(b==0){ x=1ll,y=0ll; return a; }
ll d=exgcd(b,a%b,y,x);
y-=a/b*x; return d;
}
ll inverse(ll a,ll p)
{
ll x,y,d=exgcd(a,p,x,y);
if(d==1) return (x%p+p)%p;
else return -1ll;
}
ll power(ll p,ll n)
{
ll ans=1;
while(n)
{
if(n&1){ ans*=p; ans%=MOD; }
n>>=1; p=(p*p)%MOD;
}
return ans;
}
void get_prime()
{
int cnt=0; memset(vis,0,sizeof vis);
for(int i=2;i<=a;i++)
{
if(!vis[i])
{
prime[++cnt]=i;
for(int j=i*i;j<=a;j+=i) vis[j]=1;
}
}
}
int main()
{
cin>>a>>b;
get_prime();
int cnt=1; memset(num_cnt,0,sizeof num_cnt);
for(int i=1;prime[i]*prime[i]<=a;i++)
{
if(a%prime[i]==0)
{
num[cnt]=prime[i];
while(a%prime[i]==0)
{
a/=prime[i]; num_cnt[cnt]++;
}
cnt++;
}
}
if(a!=1)
{
num[cnt]=a;
num_cnt[cnt]++;
cnt++;
}
ll ans=1;
for(int i=1;i<=cnt;i++)
{
ans*=(power(num[i],num_cnt[i]*b+1)-1)*power(num[i]-1,MOD-2);
//ans*=(power(num[i],num_cnt[i]*b+1)-1)*inverse(num[i]-1,MOD);
ans%=MOD;
}
cout<<ans<<endl;
return 0;
}
by lfcemy @ 2019-07-24 13:13:44
你的空间真是耐人寻味呀!
by littleseven @ 2019-07-24 13:16:30
@yewenyi 啥
by littleseven @ 2019-07-24 13:17:02
@yewenyi 具体一点呗
by hyfhaha @ 2019-07-24 13:17:51
头像。。。
by littleseven @ 2019-07-24 13:18:22
如果把
#define MAX 5000100
改成
#define MAX 1000005
也不行
by littleseven @ 2019-07-24 13:23:45
咋突然没人了
by 流光剑客 @ 2021-10-04 17:07:58
我开的是100000005