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 neikeda_hewei at 2009-05-02 19:45:19 on Problem 1061
#include<iostream>

using namespace std;

int main()
{
	unsigned long x,y,m,n,L;
	unsigned long k=0;
	unsigned long x1,y1;
	cin>>x>>y>>m>>n>>L;
	x1=x;
	y1=y;
	if(x!=y&&m==n)
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	while(x!=y)
	{
		x=x+m;
		if(x>=L)
			x=x%L;
		y=y+n;
		if(y>=L)
			y=y%L;
	    if(x==x1&&y==y1)
		{
			cout<<"Impossible"<<endl;
			return 0;
		}
        k++;
	}
	cout<<k<<endl;
	return 1;
}
说是Time Limit Exceeded了,高手帮看看。 


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