Dog & Gopher


Time Limit: 2 Seconds      Memory Limit: 65536 KB


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.

Input contains multiple test cases. Subsequent test cases are separated with a single blank line.

Output

Your output for each test case 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. 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

2.000 2.000 1.000 1.000

1.500 1.500

2.500 2.500

Sample Output



The gopher cannot escape.

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


Source: University of Waterloo Local Contest 1999.09.25

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

#include<iostream>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
struct point
{
double x,y;
int id;
};
point hole,ans,dog,gopher;
const double eps = 1e-6;
void dist(point hole,double &todog,double &togop)
{
todog =sqrt((dog.x - hole.x)*(dog.x - hole.x)+(dog.y-hole.y)*(dog.y-hole.y));
togop = sqrt((gopher.x - hole.x)*(gopher.x - hole.x)+(gopher.y-hole.y)*(gopher.y-hole.y));
}
char str[100];
int main()
{
while( ~scanf("%lf %lf %lf %lf\n",&gopher.x,&gopher.y,&dog.x,&dog.y))
{
int flag = 1;
double todog,togop;
while(gets(str))
{
if( strlen(str)==0)break;
sscanf(str,"%lf%lf",&hole.x,&hole.y);
dist(hole,todog,togop);
if( flag && togop < todog *0.5)
{
printf("The gopher can escape through the hole at (%.3lf,%.3lf).\n",hole.x,hole.y);
flag = 0;
}
}
if(flag)puts("The gopher cannot escape.");
}
return 0;
}

ZOJ 1860:Dog & Gopher的更多相关文章

  1. POJ 2610:Dog & Gopher

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

  2. poj 2337 有向图输出欧拉路径

    Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10186   Accepted: 2650 Descrip ...

  3. nyoj 99 单词拼接

    点击打开链接 单词拼接 时间限制:3000 ms  |  内存限制:65535 KB 难度:5 描述 给你一些单词,请你判断能否把它们首尾串起来串成一串. 前一个单词的结尾应该与下一个单词的道字母相同 ...

  4. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  5. poj2337欧拉回路要求输出路径

                         Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8368   Ac ...

  6. 洛谷P1127-词链

    Problem 洛谷P1127-词链 Accept: 256    Submit: 1.3kTime Limit: 1000 mSec    Memory Limit : 128MB Problem ...

  7. POJ 2337 Catenyms (有向图欧拉路径,求字典序最小的解)

    Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8756   Accepted: 2306 Descript ...

  8. POJ 2337 Catenyms (欧拉回路)

    Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8173   Accepted: 2149 Descript ...

  9. poj 2337(单向欧拉路的判断以及输出)

    Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11648   Accepted: 3036 Descrip ...

随机推荐

  1. TWaver 3D应用于大型数据中心(续)

    在2014年11月份,我们当时发了一篇有关TWaver HTML5 3D应用于大型数据中心的文章,该blog比较详细的描述一些常用的功能的实现方法,比如:动态添加机柜,告警,温度,湿度等相关的功能的具 ...

  2. JS中遍历EL表达式中后台传过来的Java集合

    前言:在我的项目里有这么一个情况,后台直接model.addAttribute()存储了一个对象,此对象内部有一个集合,前端JSP处理的方法正常情况下就是直接使用EL表达式即可.但是如果在JS中需要使 ...

  3. buf.writeUInt32BE()

    buf.writeUInt32BE(value, offset[, noAssert]) buf.writeUInt32LE(value, offset[, noAssert]) value {Num ...

  4. sql杂记:一些坑和数据库恢复

    这是一篇纯粹的乱七八糟的笔记...(勿喷)主要记录一下初入SQL坑的杂七杂八的注意事项. 一.先补充下事务的写法: start transaction;#开始事务 --各种事务... commit;# ...

  5. python正则表达式提取字符串

    用python正则表达式提取字符串 在日常工作中经常遇见在文本中提取特定位置字符串的需求.python的正则性能好,很适合做这类字符串的提取,这里讲一下提取的技巧,正则表达式的基础知识就不说了,有兴趣 ...

  6. type="application/javascript"

    type="application/javascript" html script 标签中 type有如下这些值,请问分别是什么意思,在什么情况下使用? type="te ...

  7. java中String,int,Integer,char、double类型转换

    java中String,int,Integer,char.double类型转换----https://www.cnblogs.com/kangyu222/p/5866025.html

  8. 46. Spring Boot中使用AOP统一处理Web请求日志

    在之前一系列的文章中都是提供了全部的代码,在之后的文章中就提供核心的代码进行讲解.有什么问题大家可以给我留言或者加我QQ,进行咨询. AOP为Aspect Oriented Programming的缩 ...

  9. kendo Cannot read property 'call' of undefined

    造成这个错误的原因是在 必须有id的定义

  10. 洛谷 P2853 [USACO06DEC]牛的野餐Cow Picnic

    P2853 [USACO06DEC]牛的野餐Cow Picnic 题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ ...