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 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 分)的更多相关文章
- 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 ...
- 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 ...
- pat05-图2. Saving James Bond - Easy Version (25)
05-图2. Saving James Bond - Easy Version (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作 ...
- 05-图2. Saving James Bond - Easy Version (25)
1 边界和湖心小岛分别算一个节点.连接全部距离小于D的鳄鱼.时间复杂度O(N2) 2 推断每一个连通图的节点中是否包括边界和湖心小岛,是则Yes否则No 3 冗长混乱的函数參数 #include &l ...
- Saving James Bond - Easy Version (MOOC)
06-图2 Saving James Bond - Easy Version (25 分) This time let us consider the situation in the movie & ...
- 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 ...
- PAT Saving James Bond - Easy Version
Saving James Bond - Easy Version This time let us consider the situation in the movie "Live and ...
- 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 ...
- 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 ...
随机推荐
- JavaScript RegExp.exec() 方法
定义和用法: exec() 方法用于检索字符串中的正则表达式的匹配. 语法: RegExpObject.exec(string); RegExpObject:必须参数,正则表达式: string:必须 ...
- CentOS7.2部署采集系统
rm -rf /etc/yum.repos.d/*scp root@192.168.48.81:/etc/yum.repos.d/* /etc/yum.repos.d/vim /etc/hosts(添 ...
- windows10 查看进程端口的情况
以程序 winnfsd.exe 为例: 1 查看进程号 PID C:\Users\leo>tasklist|findstr winnfsd.exe winnfsd.exe ...
- yum 系列(一) yum 和 rpm 常用命令
yum 系列(一) yum 和 rpm 常用命令 一.yum 常用命令 yum 命令:http://man.linuxde.net/yum yum 是在 Fedora 和 RedHat 以及 SUSE ...
- CMake使用技巧集
1.注意CMake不允许出现相同的目标名称,即使是不同的目录下的CMakeLists.txt 2.将头文件搜索路径插入到其它的前面: include_directories(BEFORE /tmp) ...
- [Selenium With C#基础教程] Lesson-03 超级链接
作者:Surpassme 来源:http://www.jianshu.com/p/83809943e751 声明:本文为原创文章,如需转载请在文章页面明显位置给出原文链接,谢谢. 超级链接或链接是We ...
- (广搜)Catch That Cow -- poj -- 3278
链接: http://poj.org/problem?id=3278 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6211 ...
- polymer技巧
1.添加一个div元素 我们完全可以自己造一个这样的东西出来,比如下面例子我们给 div 元素添加一个 is="demo-test" <script> var Poly ...
- 寻找最大的K个数(下)
接着昨天的写,里面的代码包含昨天的 #include <iostream> using namespace std; #define N 50 //初始化数组 , , , , , , , ...
- How To Use XDOLoader to Manage, Download and Upload Files? (DOC ID 469585.1)
In this Document Goal Fix Downloading Files Uploading Files References Applies to: BI Publishe ...