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 |
小弟我跪求了哪位GG MM帮帮我呀 把你qq号留下冲Q毕 谢谢了 发到邮相 magicmiaomiao@gmail.com#include<iostream> using namespace std; int main() { int s,x,y,dx,dy; while(cin>>s>>x>>y>>dx>>dy) { if(!s) break; else if(x%(2*s)>s&&y%(2*s)<s||x%(2*s)<s&&y%(s*s)>s) { cout<<"After 0 jumps the flea lands at ("<<x<<", "<<y<<")."<<endl; continue; } else if(dx%s==0&&dy%s==0&&dx%(2*s)!=0&&dy%(2*s)!=0||y%s==0&&dy%s==0||x%s==0&&dx%s==0) { cout<<"The flea cannot escape from black squares."<<endl; continue; } int a=x,b=y,c=dx,d=dy; dx=dx%(2*s); dy=dy%(2*s); x=x%(2*s); y=y%(2*s); int total=1; x=(x+dx)%(2*s); y=(y+dy)%(2*s); while(x<=s&&y<=s||x>=s&&y>=s||x==0||y==0) { total++; x=(x+dx)%(2*s); y=(y+dy)%(2*s); } cout<<"After "<<total<<" jumps the flea lands at ("<<a+total*c<<", "<<b+total*d<<")."<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator