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> #include<math.h> void main() { int i; long x,y,m,n,l; long v,xyl,sum,temp; scanf("%d%d%d%d%d",&x,&y,&m,&n,&l); if(x==y) printf("0\n"); else if(x!=y&&m==n) printf("Impossible\n"); else { if(m>n) { v=m-n; temp=x; x=y; y=temp; } //y×·x,xÏà¶Ô¾²Ö¹ else v=n-m; sum=y; i=0; while(1) { sum+=v; i++; if(sum%l==x) { printf("%d\n",i); break; } else if(sum%l==y) { printf("Impossible\n"); break; } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator