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 |
测试很多了 还是wa 那位高手帮忙看看#include <stdio.h> typedef struct { long long d,x0,y0; }Node; Node Extended_Euclid(long long a,long long b) { if(b==0) return (Node){a,1,0}; Node temp=Extended_Euclid(b,a%b); return (Node){temp.d,temp.y0,temp.x0-(a/b)*temp.y0}; } int main() { long long x,y,m,n,l; scanf("%lld %lld %lld %lld %lld",&x,&y,&m,&n,&l); long long c; if(x>y) { long long temp1,temp2; temp1=x;temp2=m; x=y;m=n; y=temp1;n=temp2; } if(m>n) c=y-x; else c=x-y+l; Node last=Extended_Euclid(abs(m-n),l); if(c%last.d||m==n) printf("Impossible\n"); else { long long xx=c*last.x0/last.d; xx%=l/last.d; if(xx<0) xx+=l/last.d; printf("%lld\n",xx); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator