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 |
大牛指教…………不解#include<stdio.h> struct triple { __int64 d,x,y; }; __int64 mod(__int64 a,__int64 b) { return (a%b+b)%b; } struct triple Extended_Euclid(__int64 a,__int64 b) { struct triple res; if(b==0) { res.d=a; res.x=1; res.y=0; } else { struct triple ee=Extended_Euclid(b,mod(a,b)); res.d=ee.d; res.x=ee.y; res.y = ee.x - (a/b)*ee.y; } return res; } __int64 MLES(__int64 a,__int64 b,__int64 l) { struct triple res; res=Extended_Euclid(a,l); if(mod(b,res.d) == 0) return mod((res.x*(b/res.d)),l/res.d); else return -1; } int main() { __int64 x,y,m,n,l; while(scanf("%I64d%I64d%I64d%I64d%I64d",&x,&y,&m,&n,&l)!=EOF) { __int64 res; res=MLES(m-n,y-x,l); if(res<0) printf("Impossible\n"); else printf("%I64d\n",res); /* if(res>=0) printf("%I64d\n",res); else printf("Impossible\n"); 就错了,上面的却ac了,为什么啊 */ } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator