Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

数据没错,运行也通过,为什么RuntimeError? 请指教一下

Posted by 05035037 at 2009-04-02 17:59:53 on Problem 1061
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator