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

为什么总是超时?大牛们指点下。急啊!!!!!

Posted by 244256770 at 2011-04-26 18:01:34 on Problem 1061
 #include<iostream>
using namespace std;
int main()
{
	unsigned  long x,y,m,n,l,t=0; 
	long r;
	cin>>x>>y>>m>>n>>l;r=y-x;
 
	while(1)
	{
                if(x==y)
		{
			cout<<"Impossible";
				break;
		}
	 
			t++;
			x+=m;y+=n;
			if(x>l)
				x%=l;
			if(y>l)
				y%=l;
			if((r<0)&&((r==(y-x)||(r==(y-l-x)))))
			{ 
                  cout<<"Impossible";
                  break;
			}
			if((r>0)&&((r==(y-x)||(r==(l-x+y))))) //这个地方有什么问题?????
				{ 
                  cout<<"Impossible";
                  break;
			}
	 
			if(x==y)
			{
				cout<<t;
			    break;
			} 
	}
			
		 
			cout<<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