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 lmsun at 2010-07-08 11:20:16 on Problem 1061
#include<iostream>
using namespace std;
int main()
{
	__int64 x,y,m,n,l;
	scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&l);
	x = x % l;
	y = y % l;
	__int64 xs = x ;
	__int64 ys = y ;
	__int64 i = 0;
	bool flag = true;
	while(true)
	{
		if( xs == ys)	break;	//走到相同地的地方了,退出
		xs = (xs + m) % l;
		ys = (ys + n) % l;
		i++;
		if(xs == x && ys == y)	//回到开始位置,退出
		{
			flag = false;
			break;	
		}
	}
	if(flag)
		printf("%I64d\n",i);
	else
		printf("Impossible\n");
	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