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 majia1234 at 2008-05-24 17:45:24 on Problem 1728 and last updated at 2008-05-24 17:47:19
#include	<iostream>
bool	chk[1000][1000];
using namespace std;
int main ()
{
	int s, x, y, dx, dy, cnt;
	while (scanf ("%d %d %d %d %d", &s, &x, &y, &dx, &dy), s != 0 || x != 0 || y != 0 || dx != 0 || dy != 0) {
		cnt = 0;
		memset (chk, false, sizeof(chk));
		chk[x%s][y%s] = true;
		while (1) {
			if (x % s == 0 || y %s == 0)
				goto nextstep;
			if (x/s%2 != y/s%2)
				break;
			nextstep:
			x += dx;	y += dy;	++ cnt;
			if (chk[x%s][y%s]) {
				puts ("The flea cannot escape from black squares.");
				goto nextcase;
			}
		}
		printf ("After %d jumps the flea lands at (%d, %d).\n", cnt, x, y);
		nextcase:
			;
	}	
}

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