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> #include <fstream> using namespace std; int main() { int x,y,m,n,len; while (cin>>x>>y>>m>>n>>len) { int dxy,dmn; x%=len; y%=len; dxy=y-x; dmn=n-m; if (x==y) { cout<<0<<endl; continue; } if (dxy<0) dxy=(len+dxy)%len; if (dmn<0) { dmn=-dmn; dxy=len-dxy; } if (dmn%len==0) cout<<"Impossible"<<endl; else { if ((len-dxy)%dmn==0) cout<<(len-dxy)/dmn<<endl; else { int cnt=0,sdxy=dxy; do { dxy+=dmn; dxy%=len; cnt++; } while (dxy!=0 && dxy!=sdxy); if (dxy==sdxy) cout<<"Impossible"<<endl; else cout<<cnt<<endl; } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator