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> long long ext_euclid(long long a,long long b,long long* x,long long* y) { long long t,d; if (b==0) { *x=1; *y=0; return a; } d=ext_euclid(b,a%b,x,y); t=*x; *x=*y; *y=t-a/b*(*y); return d; } long long modular_linear(long long a,long long b,long long n) { long long d,x,y; d=ext_euclid(a,n,&x,&y); if (b%d>0) return 0; return x*(b/d); } int main() { int m,n,x,y,l; long long ans; scanf("%d %d %d %d %d",&x,&y,&m,&n,&l); if (m==n || !(ans=modular_linear(m-n,y-x,l))) printf("Impossible\n"); else printf("%lli\n",ans+(ans<0)*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