Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:有没数据 或者过的人测试一下下面数据 谢了In Reply To:有没数据 或者过的人测试一下下面数据 谢了 Posted by:Fank at 2008-07-23 22:27:47 > 0 12312 > 12312 423 > 34547 5474571 > 12312 34534 > 5645765 5675687 > 97561 123127 > 33345 34543 > 345 1 > 1 2 > 999 50000000 程序 #include<iostream> using namespace std; #define ll long long ll mod(ll a,ll b) { ll t=1; while(b) { if(b&1==1) t=t*a%9901; a=a*a%9901; b>>=1; } return t; } ll EX_GCD(ll a,ll b,ll &x,ll &y) { ll t; if(b==0) { x=1,y=0; return a; } t=EX_GCD(b,a%b,y,x); y-=(a/b)*x; return t; } ///求求模线性方程ax=b(mod n)///// ll modexp(ll a,ll b) { ll x,y,d; d=EX_GCD(a,9901,x,y); return (x*(b/d)+9901)%9901; } int main() { bool prime[7000+100]={false}; ll p[1000],i,j,sum,ans_a,ans_b,a,b; for(i=2;i<=84;i++) if(prime[i]==false) for(j=i*i;j<=7071;j+=i) prime[j]=true; for(i=2,j=0;i<=7071;i++) if(prime[i]==false) p[j++]=i; p[j]=500000000+1; while(scanf("%lld%lld",&a,&b)!=EOF) { ans_a=ans_b=1; if(a==0) { cout<<"0"<<endl; continue; } for(i=0,j=0;p[i]<=a;i++) { if(a%p[i]==0) { sum=0; while(a%p[i]==0) { sum++; a/=p[i]; } ans_a=ans_a*(mod(p[i],sum*b+1)+9900)%9901; ans_b=ans_b*(p[i]-1)%9901; } } if(a!=1) ans_a=ans_a*(mod(a,b+1)+9900)%9901,ans_b=ans_b*(a-1)%9901; printf("%lld\n",(modexp(ans_b,ans_a)+9901)%9901); } return 0; } 一直WA的说~~~ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator