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 ...
随机推荐
- RabbitMQ系列(七)--批量消息和延时消息
批量消息发送模式 批量消息是指把消息放到一个集合统一进行提交,这种方案设计思路是希望消息在一个会话里,比如放到threadlocal里的集合,拥有相同 的会话ID,带有这次提交信息的size等属性,最 ...
- 【转载】Spring注解@Resource和@Autowired区别对比
@Resource和@Autowired都是做bean的注入时使用,其实@Resource并不是Spring的注解,它的包是javax.annotation.Resource,需要导入,但是Sprin ...
- 对vuex的一点理解
vuex是vue.js的一个状态管理工具,它适用于解决平行组件之间的数据共享问题.一般情况下,我们更多的是父子组件之间通过props或$emit来实现传值,如何不满足以上情况那只有使用vuex进行解决 ...
- 2019西安多校联训 Day4
T1 大水题!!难度简单,显然的贪心策略即可,but... 思路:首先我们按与i点作战后活下来的士兵排序,然后 若当前剩余兵力足够直接减掉战斗死亡人数,如果不够就加 够再打它,但是!我们在考完试观察测 ...
- swift中使用对象归档进行数据本地
对象归档是ios持久化中的其中一种,也是很常用的一种.现在来看看swift是如何实现的.实现要点1),必须实现NSCoding的协议 import UIKit let path=(NSSearchPa ...
- subprocess操作命令
import subprocess 一. run()方法 --->括号里面传参数,主要有cmd, stdout, shell, encoding, check 1.直接传命令 2.命令带参数要以 ...
- String类的判断功能
/* * Object:是类层级结构中的根类,所有的类都直接或间接的继承自该类. * 如果一个方法的形式参数是Object,那么这里我们就可以传递它的任意的子类对象. * * String类的判断功能 ...
- [luoguP2915] [USACO08NOV]奶牛混合起来Mixed Up Cows(DP)
传送门 f[i][S] 表示当前集合为 S,最后一个数为 i 的最优解 f[i][S] += f[j][S - i] (j, i ∈ S && j != i && ab ...
- Java 学习(6):java Number & Math & String & 数组...常用类型
目录 --- Number & Math类 --- Character 类 --- String 类 --- StringBuffer 类 --- 数组 Number & Math类: ...
- [USACO 4.2] 完美的牛栏
★★☆ 输入文件:stall4.in 输出文件:stall4.out 简单对比 时间限制:1 s 内存限制:128 MB USACO/stall4(译by Felicia Crazy) ...