| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求助:帮忙看看怎么回事?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator