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

小弟我跪求了哪位GG MM帮帮我呀 把你qq号留下冲Q毕 谢谢了 发到邮相 magicmiaomiao@gmail.com

Posted by miaomiaomiaomiao at 2006-04-12 16:40:56 on Problem 1728
#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:
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