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 sicojuy at 2010-09-08 16:02:22 on Problem 1061
#include <stdio.h>

int main()
{
	unsigned long x,y,m,n,l,s,t=0;  //t为跳的次数
	scanf("%ld%ld%ld%ld%ld",&x,&y,&m,&n,&l);

	s = x - y;                      //s为两只青蛙的距离
	if(s == 0)                      //一开始就在一起
		printf("%ld\n",t);
	else
	{
		while(1)
		{
			x = x + m;
			y = y + n;
			x = x % l;      //跳一次后的坐标
			y = y % l;
			t++;
			if(x == y)      //相遇
			{
				printf("%ld\n",t);
				break;
			}
			else if(x-y == s || x-y == l-1) //两只青蛙的距离和开始一样
 			{
				printf("Impossible");
				break;					
			}	
		}
	}
	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