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. 每天一道算法题(24)——自定义幂函数pow

    double myPower(double base, int exponent){ if(exponent==0) return 1; if(exponent==1) return base; if ...

  2. JavaScript的作用域与闭包

    JavaScript的作用域以函数为界,不同的函数拥有相对独立的作用域.函数内部可以声明和访问全局变量,也可以声明局部变量(使用var关键字,函数的参数也是局部变量),但函数外部无法访问内部的局部变量 ...

  3. Java-马士兵设计模式学习笔记-工厂模式-简单工厂

    一.概述 1.目标:要控制任意类型交通工具的生产模式 2.目标有两层意思(1)任意类型 (2)生产模式,所以对应的,要这两个层面上抽象(Movable,VehicleFactory),利用接口,实现多 ...

  4. 如何使用EditPlus将json格式字符串默认为UTF-8格式

    1.首先用EditPlus打开json格式的文件 2.选择Tools工具栏下的Configure  User Tools 3.点击左侧File 4.在右侧Default encoding中选择UTF- ...

  5. EZOJ #78

    传送门 分析 AC自动机板子题qwq 不过似乎可以哈希(因为所有模式串的长度相同,所以哈希乱搞就可以) 代码 #include<iostream> #include<cstdio&g ...

  6. Luogu 3759 [TJOI2017]不勤劳的图书管理员

    再也不作死写FhqTreap作内层树了,卡的不如暴力呜呜呜…… 题意翻译:给一个序列,每个下标包含两个属性$a$和$v$,求第一个属性与下标形成的所有逆序对的第二个属性和,给出$m$个交换两个下标的操 ...

  7. 使用database control配置数据库时 要求在当前oracle主目录中配置监听程序

    1:配置本地的环境变量 打开cmd命令界面  C:\Users\gechong>lsnrctl start 这时候报适配器错误 2.在cmd中输入 tnslsnr命令

  8. Entity Framework Tutorial Basics(29):Stored Procedure in Entity Framework

    Stored Procedure in Entity Framework: Entity Framework has the ability to automatically build native ...

  9. Java Annotation详解

    元数据的作用 如果要对于元数据的作用进行分类,目前还没有明确的定义,不过我们可以根据它所起的作用,大致可分为三类: l          编写文档:通过代码里标识的元数据生成文档. l         ...

  10. 美团热更新Robust Demo演示

    1.Android Studio clone 远程Robust项目源码 gradle 同步依赖资源,可能需要半个小时左右. 2.生成样例apk包 配置app module下build.gradle 插 ...