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

WHY PE?

Posted by RE at 2006-09-22 16:41:48 on Problem 2610
#include<stdio.h>
#include<iostream>
using namespace std;

typedef struct point{
	float x;
	float y;
}point;

int main()
{
    point dog,gopher;
	point e;
	point escape;
	bool flag=false;
	float a,b;

	scanf("%f%f%f%f",&gopher.x,&gopher.y,&dog.x,&dog.y);
    
	while(scanf("%f%f",&e.x,&e.y)!=EOF)
	{
	    a=4*((gopher.x-e.x)*(gopher.x-e.x)+(gopher.y-e.y)*(gopher.y-e.y));
		b=((dog.x-e.x)*(dog.x-e.x)+(dog.y-e.y)*(dog.y-e.y));
		if(flag==false&&a<b)
		{
			flag=true;
			escape=e;
			break;
		}
   	}
	if(flag==false)
	{
		printf("The gopher cannot escape.\n");
	}
    if(flag==true)
	{
		printf("The gopher can escape through the hole at(%.3f,%.3f).\n",escape.x,escape.y);
	}
	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