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 |
数据没错,运行也通过,为什么RuntimeError? 请指教一下#include<iostream> using namespace std; int main() { int x,y,m,n,L; while(cin>>x>>y>>m>>n>>L) { if(m==n) { cout<<"Impossible"<<endl; continue; } y=y%L; x=x%L; m=m%L; n=n%L; if(m<n) { int t=m; m=n; n=t; t=x; x=y; y=t; } if(y<x) y+=L; int a=L%(m-n),b=(y-x)%(m-n); for(int i=0;i<m-n;i++) { if((i*a+b)%(m-n)==0) { cout<<(i*L+(y-x))/(m-n)<<endl; break; } if(i==m-n-1) cout<<"Impossible"<<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