| ||||||||||
| 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 | |||||||||
这题通过率挺高的,为什么我就WA,哪位大大看一下我的程序,是不是算法错了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator