Dog & Gopher
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 4142   Accepted: 1747

Description

A large field has a dog and a gopher. The dog wants to eat the gopher, while the gopher wants to run to safety through one of several gopher holes dug in the surface of the field. 

Neither the dog nor the gopher is a math major; however, neither is entirely stupid. The gopher decides on a particular gopher hole and heads for that hole in a straight line at a fixed speed. The dog, which is very good at reading body language, anticipates
which hole the gopher has chosen, and heads at double the speed of the gopher to the hole, where it intends to gobble up the gopher. If the dog reaches the hole first, the gopher gets gobbled; otherwise, the gopher escapes. 



You have been retained by the gopher to select a hole through which it can escape, if such a hole exists. 

Input

The first line of input contains four floating point numbers: the (x,y) coordinates of the gopher followed by the (x,y) coordinates of the dog. Subsequent lines of input each contain two floating point numbers: the (x,y) coordinates of a gopher hole. All distances
are in metres, to the nearest mm.

Output

Your output should consist of a single line. If the gopher can escape the line should read "The gopher can escape through the hole at (x,y)." identifying the appropriate hole to the nearest mm. Otherwise the output line should read "The gopher cannot escape."
If the gopher may escape through more than one hole, choose the first one in the input. If the gopher and dog reach the hole at the same time, the gopher gets gobbled. There are not more than 1000 gopher holes and all coordinates are between -10000 and +10000.

Sample Input

1.000 1.000 2.000 2.000
1.500 1.500

Sample Output

The gopher cannot escape.

Hint

Sample Input 2 

2.000 2.000 1.000 1.000 

1.500 1.500 

2.500 2.500 



Output for Sample Input 2 

The gopher can escape through the hole at (2.500,2.500). 


Source

迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define eps 1.0E-8
double xx1,xx2,yy1,yy2;
double dist(double x1, double y1, double x2, double y2)
{
double x = abs(x1 - x2);
double y = abs(y1 - y2);
return sqrt(x * x + y * y);
}
bool ok(double x, double y)
{
double d1 = dist(xx1, yy1, x, y);
double d2 = dist(xx2, yy2, x, y);
if (d1 * 2 + eps < d2)
return true;
return false;
}
int main()
{
scanf("%lf%lf%lf%lf",&xx1,&yy1,&xx2,&yy2);
double x, y;
while (~scanf("%lf%lf",&x,&y))
{
if (ok(x,y))
{
printf("The gopher can escape through the hole at (%.3f,%.3f).\n", x, y);
return 0;
}
}
printf("The gopher cannot escape.\n");
return 0;
}

最新文章

  1. URL重写 urlrouting
  2. Android 手机卫士5--手机防盗
  3. ArcGIS API for Silverlight之配准JPG图片地图文字倾斜解决方案
  4. html body的属性 格式控制标签 内容容器标签 超链接标签 图片标签 表格
  5. ScalaTour 2.函数
  6. Jmeter 使用笔记之 html 报告扩展(一)
  7. poj2154
  8. Terminating app due to uncaught exception &#39;NSUnknownKeyException&#39; this class is not key value coding-compliant for the key
  9. poj2479 最大子段和
  10. activiti实战系列 activiti连线
  11. 《java入门第一季》二维数组三个案例详解
  12. JS的forEach和map方法的区别
  13. MySQL备份恢复-mysqldump原理
  14. windows 安装python pip Could not install packages due to anEnvironmentError: [WinError 5] 拒绝访问
  15. pygame将文字保存为图片形式
  16. 【Loadrunner】Loadrnner 参数化策略
  17. AtCoder Regular Contest 100 Equal Cut
  18. Filter接口编写过滤器
  19. php Pthread 多线程 (四) 共享内存
  20. 转载 --iOS实用小技巧(2)-生成txt文本

热门文章

  1. 用 webpack 实现持久化缓存
  2. Install Zabbix with Docker
  3. 关于vuex的理解
  4. Luogu P1540 机器翻译
  5. linux diff3-比较3个文件不同的地方
  6. python爬取酷狗音乐排行榜
  7. Python-组合数据类型
  8. mysql 5.5与5.6 timestamp 字段 DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP的区别
  9. 清北学堂模拟赛d1t1 位运算1(bit)
  10. jquery追加元素的几种方法(append()、prepend()、after()、before()、insertAfter()、insertBefore())