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

这题通过率挺高的,为什么我就WA,哪位大大看一下我的程序,是不是算法错了

Posted by windbells at 2004-08-03 10:16:40 on Problem 1728
#include<stdio.h>
int main()
{
	__int64 s,x,y,dx,dy,i,x1,y1;
	while(scanf("%I64d%I64d%I64d%I64d%I64d",&s,&x,&y,&dx,&dy)!=EOF)
	{
		if(s+x+y+dx+dy==0)
			break;
		x1=x%s;y1=y%s;
		for(i=0;;i++)
		{
			if(i!=0)
			{
				x+=dx;
				y+=dy;
			}
			if(x%s!=0&&y%s!=0&&(x/s+y/s)%2==1)
			{
				printf("After %I64d jumps the flea lands at (%I64d, %I64d).\n",i,x,y);
				break;
			}
			else if(i!=0&&x%s==x1&&y%s==y1)
			{
				printf("The flea cannot escape from black squares.\n");
				break;
			}
		}
	}
}


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