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:Re:给几组大数测试数据 Posted by:8819 at 2009-08-14 13:02:06 > 我都能对,为什么还是WA呀? #include<stdio.h> struct triple{ __int64 d,x,y; }; __int64 gcd(__int64 a,__int64 b) { if(b==0) return a; else return gcd(b,a%b); } __int64 mod(__int64 a,__int64 b) { if(a>0) return a%b; else return a%b+b; } triple exgcd(__int64 a,__int64 b) { triple result; if(b==0) { result.d=a; result.x=1; result.y=0; } else { triple ee=exgcd(b,mod(a,b)); result.d=ee.d; result.x=ee.y; result.y=ee.x-(a/b)*ee.y; } return result; } __int64 MILS(__int64 a,__int64 b,__int64 l) { __int64 x; triple ee=exgcd(a,l); if(mod(b,ee.d)==0) { x=mod(ee.x*(b/ee.d),l/ee.d); return printf("%I64d",x); } else return printf("impossble!"); } int main() { __int64 x,y,m,n,l,a,b; scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&l); b=y-x; a=m-n; if(b<0) { b=-b; a=-a; } MILS(a,b,l); return 0; } 谁能告诉我一下? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator