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 (≤100), the number of crocodiles, and D, the maximum distance that James could jump. Then N lines follow, each containing the (x,y) 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 double ISLAND_RADIUS = 15.0 / ;
const double SQUARE_SIZE = 100.0;
const int maxn = ; typedef struct Point{
double x,y;
}Position; Position P[maxn];
int n;
double d;
bool vis[maxn]; void save007();
bool FirstJump(int v);
bool DFS(int v);
bool isSave(int v);
bool Jump(int v1,int v2); int main(){
scanf("%d %lf",&n,&d);
for(int i = ; i < n; i++){
scanf("%lf %lf",&(P[i].x),&(P[i].y));
}
for(int i = ; i < n; i++){
vis[i] = false;
}
save007();
return ;
} void save007(){
bool isVist = false;
for(int i = ; i < n; i++){
if(!vis[i] && FirstJump(i)){
isVist = DFS(i);
if(isVist) break;
}
}
if(isVist) printf("Yes\n");
else printf("No\n");
} bool FirstJump(int v){
return sqrt(P[v].x * P[v].x + P[v].y * P[v].y) <= d + ISLAND_RADIUS;
} bool DFS(int v){
bool answer = false;
vis[v] = true;
if(isSave(v)) return true;
for(int i = ; i < n; i++){
if(!vis[i] && Jump(v,i)){
answer = DFS(i);
}
if(answer) break;
}
return answer;
} bool isSave(int v){
return (abs(P[v].x) >= - d) || (abs(P[v].y) >= - d);
} bool Jump(int v1,int v2){
return sqrt((P[v1].x - P[v2].x)*(P[v1].x - P[v2].x) + (P[v1].y - P[v2].y) * (P[v1].y - P[v2].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 ...

  10. 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 ...

随机推荐

  1. mahout in Action研读(1)-给用户推荐图书

    1.mahout in Action2.2第一个例子   Running a first recommender engine   数据: 第一个数字是用户ID 第二个是书的ID,第三个是用户对书的评 ...

  2. matlab图片高清复制到visio

    编辑→复制图窗→在visio中粘贴

  3. python爬虫实战(2)--爬取百度贴吧

    本篇目标 1.对百度贴吧的任意帖子进行抓取 2.指定是否只抓取楼主发帖内容 3.将抓取到的内容分析并保存到文件 1.URL格式的确定 先观察百度贴吧url格式,以中南财经政法大学迎新帖为例,URL我们 ...

  4. WPA密码攻击宝典

    原则:密码以8-10位为主.11位仅限于当地手机号.一般人的多年用数字做密码的习惯和心理,先数 字.再字母,或数字.字母重复几遍,字符几乎全用小写,所以淘汰大写及"~!@#$%^&* ...

  5. a标签中href=""的几种用法(转)

    a标签中href=""的几种用法   标签: html / a标签 / javascript 46371 众所周知,a标签的最重要功能是实现超链接和锚点.而且,大多数人认为a标签最 ...

  6. __tostring和__invoke 方法

    首先放上代码: <?php class MagicTest{ //__tostring会在把对象转换为string的时候自动调用 public function __tostring() { r ...

  7. UITableView(可滚动到顶部和底部)

    #import "RootViewController.h" #define width [UIScreen mainScreen].bounds.size.width #defi ...

  8. 30-盐水(分段dfs)

    链接:https://www.nowcoder.com/acm/contest/94/K来源:牛客网 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 131072K,其他语言2621 ...

  9. ROS Learning-004 beginner_Tutorials 介绍简单的ROS命令

    ROS Indigo beginner_Tutorials-03 介绍简单的ROS命令 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu 14.04 ...

  10. 安装Fastqc软件遇到的坑

    由于之前的HPC太难用了,所以决定搬家到十楼的工作站,于是就免不了配置必要的工作环境,其中一个少不了要安装的软件是就是fastqc,因为它太常用了. 我先是用conda安装,因为conda实在是太方便 ...