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 |
现在付上我的程序,请大家帮忙看看In Reply To:能不能给一下测试数据啊 。。。 我的程序老是wa,但是我自己测试的,和一个ac的程序得到的答案是一样的啊 Posted by:malongzl at 2004-06-12 01:08:42 #include "stdio.h" void main() { unsigned long x,y,m,n,l; scanf("%ld %ld %ld %ld %ld",&x,&y,&m,&n,&l); if (m==n) printf("Impossible\n"); else { if(m>n) {m=m-n;x=(y-x+l)%l;} else {m=n-m;x=(x-y+l)%l;} 把其中移动比较慢的那个当做不动。 n=x/m;x=x%m;y=x; 用相对运动的思想。 while(1) { if(y==0) {printf("%ld\n",n);break;} 当两个人的距离等于零时 y=(y+l)%m;n=n+(y+l)/m; if(y==x) {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