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. Composite模式 组合模式

    Android的ViewGroup 和 View 的关系,即是采用组合模式 1. 概述 在数据结构里面,树结构是很重要,我们可以把树的结构应用到设计模式里面. 例子1:就是多级树形菜单. 例子2:文件 ...

  2. 关联查询 join的使用

    #!/usr/bin/env python import sqlalchemy from sqlalchemy import create_engine from sqlalchemy.ext.dec ...

  3. oracle --(二)分区(extent)

    基本关系:数据库---表空间---数据段---分区---数据块 一.分区(extent)分区extent是比数据块大一级的存储结构,是几个逻辑上相邻的data block的组合.我们知道,物理存储通常 ...

  4. 连接ORACLE客户端工具navicat111.12 for oracle

    安装navicat111.12 for oracle后 打开

  5. 开源项目weiciyuan运行前gradle调试过程记录

    折腾了几个小时,终于能成功运行了,由于该项目使用的gradle版本过旧,需要做一些调整,具体如下 1.将使用gradle版本号改为你现在用的 2.将build tools版本号改为同上 3.将defa ...

  6. 去除Activity上面的标题边框

    实现方法:1.在代码中实现:在此方法setContentView(R.layout.main)之前加入:requestWindowFeature(Window.FEATURE_NO_TITLE);标题 ...

  7. 用于.NET环境的时间测试(转)

    用于.NET环境的时间测试   在.NET环境中,衡量运行完整算法所花费的时间长度,需要考虑很多 需要考虑很多种情况 ,如:程序运行所处的线程以及无用单位收集(GC垃圾回收). 在程序执行过程中无用单 ...

  8. Windows 安装 Microsoft Visual Studio 2010

    Windows 安装 VS2010 我的电脑系统:Windows 10 x64位 我要安装的Microsoft Visual Studio 是:VS2010 注意: VS2010 没有专门的64位版. ...

  9. Luogu 2467 [SDOI2010]地精部落

    挺有意思的题. 优质题解: https://www.luogu.org/blog/user55639/solution-p2467 题意为求长度为n,取值为$[1, n]$的波动序列的个数. 首先需要 ...

  10. Failed to export using the options you specified. Please check your options and try again

    参考这篇<从ASP.NET传递参数给水晶报表> http://www.cnblogs.com/insus/p/3281114.html  是可以传递参了.但是点击报表的菜单条上的打印图标没 ...