POJ 2610:Dog & Gopher
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 4142 | Accepted: 1747 |
Description
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
are in metres, to the nearest mm.
Output
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
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的更多相关文章
- ZOJ 1860:Dog & Gopher
Dog & Gopher Time Limit: 2 Seconds Memory Limit: 65536 KB A large field has a dog and a gop ...
- POJ 2610
#include<iostream> #include<iomanip> using namespace std; int main() { //freopen("a ...
- POJ 2536 之 Gopher II(二分图最大匹配)
Gopher II Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6675 Accepted: 2732 Descrip ...
- poj 2337 有向图输出欧拉路径
Catenyms Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10186 Accepted: 2650 Descrip ...
- POJ 2337 Catenyms (有向图欧拉路径,求字典序最小的解)
Catenyms Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8756 Accepted: 2306 Descript ...
- POJ 2337 Catenyms (欧拉回路)
Catenyms Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8173 Accepted: 2149 Descript ...
- poj 2337(单向欧拉路的判断以及输出)
Catenyms Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11648 Accepted: 3036 Descrip ...
- 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 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
随机推荐
- Linux的网卡由eth0变成了eth1或eth2,如何修复??
背景:做linux下分布式测试的时候,重新安装了两个linux虚拟机,结果分布式脚本没有做好,分布式也没有做成. 今天想练练linux命令,打开vmware,启动linux1 虚拟机,使用ifconf ...
- RocketMQ学习笔记(16)----RocketMQ搭建双主双从(异步复制)集群
1. 修改RocketMQ默认启动端口 由于只有两台机器,部署双主双从需要四个节点,所以只能修改rocketmq的默认启动端口,从官网下载rocketmq的source文件,解压后使用idea打开,全 ...
- LeetCode141LinkedListCycle和142LinkedListCycleII
141题:判断链表是不是存在环! // 不能使用额外的存储空间 public boolean hasCycle(ListNode head) { // 如果存在环的 两个指针用不一样的速度 会相遇 L ...
- Luogu P2176 [USACO14FEB]路障Roadblock
解题思路 这是一道最短路题目,不知道大家有没有做过玛丽卡这道题目,如果没做,在做完这道题之后可以去拿个双倍经验哦 先求出一张图中的最短路径,并将其记录下来,我们首先思考:要有增量的前提是新的最短路径比 ...
- 类与类之间的关系UML模型图
关联.依赖.聚合.组合.泛化.实现 类之间可能存在以下几种关系:关联(association).依赖(dependency).聚合(Aggregation,也有的称聚集).组合(Composition ...
- java导出word的6种方式(转发)
来自: http://www.cnblogs.com/lcngu/p/5247179.html 最近做的项目,需要将一些信息导出到word中.在网上找了好多解决方案,现在将这几天的总结分享一下. 目前 ...
- PHP 计数排序
计数排序不是基于比较的排序算法,其核心在于将输入的数据值转化为键存储在额外开辟的数组空间中. 作为一种线性时间复杂度的排序,计数排序要求输入的数据必须是有确定范围的整数. 算法描述 找出待排序的数组中 ...
- 一:安装centos 7最小编程环境 xfce桌面
1, u盘制作安装盘------------------------------------------------------安装时, table或者e进入编辑选项 如果不知道你的u盘的盘符 ...
- Python字符串(Python学习笔记02)
字符串 Python 3 中的字符串可以使用双引号或单引号标示,如果字符串出现引号,则可以使用 \ 来去除引号标示字符串的作用. 几种字符串的表示方法: str1 = "hello" ...
- Vue.Draggable实现拖拽效果(采坑小记)
之前有写过Vue.Draggable实现拖拽效果(快速使用)(http://www.cnblogs.com/songdongdong/p/6928945.html)最近项目中要用到这个拖拽的效果,当产 ...