This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land at the center of a lake filled with crocodiles. There he performed the most daring action to escape -- he jumped onto the head of the nearest crocodile! Before the animal realized what was happening, James jumped again onto the next big head... Finally he reached the bank before the last crocodile could bite him (actually the stunt man was caught by the big mouth and barely escaped with his extra thick boot).

Assume that the lake is a 100 by 100 square one. Assume that the center of the lake is at (0,0) and the northeast corner at (50,50). The central island is a disk centered at (0,0) with the diameter of 15. A number of crocodiles are in the lake at various positions. Given the coordinates of each crocodile and the distance that James could jump, you must tell him whether or not he can escape.

Input Specification:

Each input file contains one test case. Each case starts with a line containing two positive integers N (≤), the number of crocodiles, and D, the maximum distance that James could jump. Then N lines follow, each containing the ( location of a crocodile. Note that no two crocodiles are staying at the same position.

Output Specification:

For each test case, print in a line "Yes" if James can escape, or "No" if not.

Sample Input 1:

14 20
25 -15
-25 28
8 49
29 15
-35 -2
5 28
27 -29
-8 -28
-20 -35
-25 -20
-13 29
-30 15
-35 40
12 12

Sample Output 1:

Yes

Sample Input 2:

4 13
-12 12
12 12
-12 -12
12 -12

Sample Output 2:

No
#include<cstdio>
#include<cmath>
#include<cstdlib> const int maxn = ;
const double ISLAND_RADIUS = 15.0/;
const double SQUARE_SIZE = 100.0; typedef struct Point{
double x,y;
}Position; Position P[maxn];
int n;
double d;
bool isVis[maxn] = {false}; void Save007();
bool FirstJump(int v);
bool DFS(int v);
bool Jump(int v1,int v2);
bool Judge(int v); int main(){
scanf("%d%lf",&n,&d);
for(int i = ; i < n; i++){
scanf("%lf%lf",&P[i].x,&P[i].y);
} Save007();
return ;
} void Save007(){
bool isSave = false;
for(int i = ; i < n; i++){
if(!isVis[i] && FirstJump(i)){
isSave = DFS(i);
if(isSave) break;
}
}
if(isSave) printf("Yes");
else printf("No");
} bool FirstJump(int v){
double x = pow(P[v].x,);
double y = pow(P[v].y,);
double dis = sqrt(x+y);
return dis <= d + ISLAND_RADIUS;
} bool DFS(int v){
bool answer = false;
isVis[v] = true;
if(Judge(v)) return true;
for(int i = ; i < n; i++){
if(!isVis[i] && Jump(v,i)){
answer = DFS(i);
}
if(answer) break;
}
if(answer) return true;
else return false;
} bool Jump(int v1,int v2){
int x = P[v1].x - P[v2].x;
int y = P[v1].y - P[v2].y;
double dis = sqrt(pow(x,) + pow(y,));
return dis <= d;
} bool Judge(int v){
return (abs(P[v].x) >= - d || abs(P[v].y) >= -d);
}

06-图2 Saving James Bond - Easy Version (25 分)的更多相关文章

  1. PTA 06-图2 Saving James Bond - Easy Version (25分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

  2. 06-图2 Saving James Bond - Easy Version (25 分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

  3. pat05-图2. Saving James Bond - Easy Version (25)

    05-图2. Saving James Bond - Easy Version (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作 ...

  4. 05-图2. Saving James Bond - Easy Version (25)

    1 边界和湖心小岛分别算一个节点.连接全部距离小于D的鳄鱼.时间复杂度O(N2) 2 推断每一个连通图的节点中是否包括边界和湖心小岛,是则Yes否则No 3 冗长混乱的函数參数 #include &l ...

  5. Saving James Bond - Easy Version (MOOC)

    06-图2 Saving James Bond - Easy Version (25 分) This time let us consider the situation in the movie & ...

  6. Saving James Bond - Easy Version 原创 2017年11月23日 13:07:33

    06-图2 Saving James Bond - Easy Version(25 分) This time let us consider the situation in the movie &q ...

  7. PAT Saving James Bond - Easy Version

    Saving James Bond - Easy Version This time let us consider the situation in the movie "Live and ...

  8. PTA 07-图5 Saving James Bond - Hard Version (30分)

    07-图5 Saving James Bond - Hard Version   (30分) This time let us consider the situation in the movie ...

  9. 06-图2 Saving James Bond - Easy Version

    题目来源:http://pta.patest.cn/pta/test/18/exam/4/question/625 This time let us consider the situation in ...

随机推荐

  1. MinDos--操作系统

    MinDos--操作系统 总结 : 本次实现的是功能是为 (1)自行定义系统提示符 (2)自定义命令集(8-10个) (3)用户输入HELP以查找命令的帮助 (4)列出命令的功能,区分内部还是外部命令 ...

  2. oepnni安装

    sudo apt-get install libopenni-dev libopenni2-dev / apt-get install libqhull-dev

  3. .net手动编写Windows服务

    1,打开VS,新建一个windows服务程序.项目名称自定义,我这里用的默认名称:Service1 2,打开Service1,按F7查看代码.代码里有三个方法:public Service1().pr ...

  4. 第十届国际用户体验创新大赛携Mockplus走进校园

    今日立夏,万木并秀,生生不息,第十届国际用户体验创新大赛即将拉开序幕.5月5日下午,一场用户体验设计经验分享活动携带众多嘉宾降临成都理工大学,为西南赛区首站赛事宣讲. 本次宣讲活动邀请了华为技术有限公 ...

  5. Mac下eclipse 启动时出现An error has occurred. See the log file的问题

    eclipse原来可以使用的好好的,装了多个版本的jdk后,打开eclipse出现An error has occurred. See the log file的问题,经过查找,可能原因之一是机子装了 ...

  6. Oracle学习笔记(六)

    八.函数 1.函数的作用 (1)方便数据的统计 (2)处理查询结果,让数据显示更清楚 2.函数分类(提供很多内置函数,也可自定义函数) (1)数值函数 平均值,四舍五入 a.四舍五入 表达式 roun ...

  7. spark standalone集群部署 实践记录

    本文记录了一次搭建spark-standalone模式集群的过程,我准备了3个虚拟机服务器,三个centos系统的虚拟机. 环境准备: -每台上安装java1.8 -以及scala2.11.x (x代 ...

  8. http://www.rabbitmq.com/

    什么是RabbitMQ 官网http://www.rabbitmq.com/ 1.应用程序间健壮的消息发送 2.简单易用 3.可在所有主流操作系统运行 4.支持巨量的开发者平台 5.开源和商用双重支持 ...

  9. JAVA AQS源码分析

    转自:  http://www.cnblogs.com/pfan8/p/5010526.html JAVA AQS的全称为(AbstractQueuedSynchronizer),用于JAVA多线程的 ...

  10. 解决ie img标签内存泄漏

    代码: <html> <head> <meta http-equiv="Content-Type" content="text/html; ...