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;
}

POJ 2610:Dog & Gopher的更多相关文章

  1. ZOJ 1860:Dog & Gopher

    Dog & Gopher Time Limit: 2 Seconds      Memory Limit: 65536 KB A large field has a dog and a gop ...

  2. POJ 2610

    #include<iostream> #include<iomanip> using namespace std; int main() { //freopen("a ...

  3. POJ 2536 之 Gopher II(二分图最大匹配)

    Gopher II Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6675   Accepted: 2732 Descrip ...

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

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

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

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

  6. POJ 2337 Catenyms (欧拉回路)

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

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

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

  8. Day 4 -E - Catenyms POJ - 2337

    A catenym is a pair of words separated by a period such that the last letter of the first word is th ...

  9. HOJ题目分类

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

随机推荐

  1. Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

    WebsocketSourceConfiguration { @Bean ServletWebServerFactory servletWebServerFactory(){ return new T ...

  2. TWaver3D特效之高光反射

    前篇我们介绍了TWaver 3D的环境映射特效,下面我们接着给大家分享高光反射特效.高光反射定义了物体上的某一区域比其他地方更反光.在高光反射的贴图中,黑色区域的反射率为0(完全不反光),白色区域的反 ...

  3. 个人总结的常用java,anroid网站

    http://blog.csdn.net/wanghao200906/article/details/49334987

  4. [Algorithm] 8. Rotate String

    Description Given a string and an offset, rotate string by offset. (rotate from left to right) Examp ...

  5. pygame 方块随机飞舞动画

    import pygame import random # default WIDTH=1280 HEIGHT=1060 FPS=60 sum=0 # set color WHITE=(255,255 ...

  6. 魂酥的NOIP2018(真实)游记

    NOIP之后才开博客 作为一个高一零基础蒟蒻 想说什么似乎也没什么可说的 才学几个月似乎也没什么发言权就是了 Day -1 期中考爆0,似乎是班里学OI的考得最惨的一个 岂不美哉 要么我也没想考好 也 ...

  7. Centos7二进制文件安装MySQL5.7.25

    1.删除centos系统自带的mariadb数据库防止发生冲突 rpm -qa|grep mariadb rpm -e mariadb-libs --nodeps 2.安装libaio库 yum -y ...

  8. linux time-统计给定命令所花费的总时间

    推荐:更多linux 性能监测与优化 关注:linux命令大全 time命令用于统计给定命令所花费的总时间. 语法 time(参数) 参数 指令:指定需要运行的额指令及其参数. 实例 当测试一个程序或 ...

  9. BZOJ 1782 洛谷 2982 [Usaco2010 Feb]slowdown 慢慢游

    [题解] 一头牛走到i,相当于把i点的子树的点权都加1,查询减慢的次数就是查询目的地的点权. 预处理dfs序,某个点的子树的dfs序是连续的一段.差分后用树状数组维护,变成点修区查.或者直接线段树区修 ...

  10. unigui导出TMS.Flexcel【5】

    参考代码 procedure TUniFrmeWebEmbedBase.ExportData; //导出到excel var FlexCelImport1: TExcelFile; i, rowind ...