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 <iostream> using namespace std; int main() { long x,y,m,n,l; do cin >> x >> y>>m>>n>>l; while ( !(x!=y&&x<2000000000&&y<2000000000&&m>0 //验证输入数据合法性 &&m<2000000000&&n>0&&n<2000000000 &&l>0&&l<2100000000) ); x=(x+l)%l; //x,y坐标变成正直 y=(y+l)%l; if(m==n) { cout<<"impossible"<<endl; return 0; } long i=y+n-m,num=1; while( ((i+l)%l)!=x&& ((i+l)%l)!=y) //如果有重复点或者追到a就退出 { i=(i+n-m)%l; num++; } if(((i+l)%l)==y) cout<<"impossible";//重复点 else cout<<num<<endl; return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator