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

感觉我这个程序应该没错 可就是通不过有高手能给我看看吗 输入了N组数据都能行

Posted by fqq12358 at 2009-08-01 14:00:57 on Problem 1061
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long  i,x,y,n,m,l;
	long  z;
	cin>>x>>y>>n>>m>>l;
	if(x==y||x>=2000000000||y>=2000000000)
	{
		if(n>=2000000000||m>=2000000000||n<0||m<0||l>=2100000000)
		exit(0);
	}
	if((x>y&&n<m)||(x<y&&n>m))
	{
		for(i=0;i<=abs(n-m);i++)
		{
			z=(abs(y-x));
			if((i*l+z)%abs(n-m)==0)
			{
				cout<<(i*l+z)%abs(n-m);
				break;
			}
		}
	}
	else if((x<y&&n<m)||(x>y&&n>m))
	{

		for(i=0;i<=abs(n-m);i++)
		{
			z=(abs(y-x));
			if((i*l-z+l)%(n-m)==0)
			{
				cout<<(i*l-z+l)/abs(n-m);
				break;
			}
		}
	}
	else if(m==n)
	{
		cout<<"Impossible";
		return 0;
	}
	if(i==abs(n-m)+1)
	{cout<<"Impossible";}
	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