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 |
a<0In Reply To:Re:怎么会WA,谢谢 Posted by:PC0400322032 at 2004-09-05 22:52:42 > #include <stdio.h> > int a,p; > __int64 mod2(int k) > { > int i; > __int64 m; > m = a%p; > for(i=0;i<k;i++) > m = (m*m)%p; > return m; > } > int done() > { > int k,q=p/2; > __int64 m(1); > for(k=0;k<32;k++) > if(((1<<k)&q)>0) > m = m*mod2(k)%p; > if(m==1) > return 1; > else > return -1; > } > void main() > { > int t,tt; > scanf("%d",&tt); > for(t=1;t<=tt;t++) > { > scanf("%d%d",&a,&p); a=a%p;a=(a+p)%p; > printf("Scenario #%d:\n%d\n\n",t,done()); > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator