POJ 1473 There's Treasure Everywhere!
小小的模拟一下。
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
char str[];
double a[];
double b[];
void CL()
{
a[] = a[] = 0.0;
a[] = a[] = sqrt(2.0)/2.0;
a[] = 1.0;
a[] = -1.0;
a[] = a[] = -sqrt(2.0)/2.0;
b[] = 1.0;
b[] = -1.0;
b[] = b[] = sqrt(2.0)/2.0;
b[] = b[] = 0.0;
b[] = b[] = -sqrt(2.0)/2.0;
}
int judge(int x)
{
if(str[x+] == ','||str[x+] == '.')
{
if(str[x] == 'N')
return ;
else if(str[x] == 'E')
return ;
else if(str[x] == 'S')
return ;
else if(str[x] == 'W')
return ;
}
else
{
if(str[x] == 'N'&&str[x+] == 'E')
return ;
else if(str[x] == 'S'&&str[x+] == 'E')
return ;
else if(str[x] == 'S'&&str[x+] == 'W')
return ;
else if(str[x] == 'N'&&str[x+] == 'W')
return ;
}
return ;
}
int main()
{
int len,i,cas = ,pre,j,temp;
double x,y;
CL();
while(scanf("%s",str)!=EOF)
{
if(strcmp(str,"END") == ) break;
len = strlen(str);
pre = ;
x = y = ;
for(i = ; i < len; i ++)
{
if(str[i] == ','||str[i] == '.')
{
temp = ;
for(j = pre; j < i; j ++)
{
if(str[j] <= ''&&str[j] >= '')
temp = temp* + str[j] - '';
else
break;
}
x += temp*a[judge(j)];
y += temp*b[judge(j)];
pre = i+;
}
}
printf("Map #%d\n",cas++);
printf("The treasure is located at (%.3f,%.3f).\n",x,y);
printf("The distance to the treasure is %.3f.\n\n",sqrt(x*x+y*y));
}
return ;
}
POJ 1473 There's Treasure Everywhere!的更多相关文章
- poj 2594 Treasure Exploration (二分匹配)
Treasure Exploration Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 6558 Accepted: 2 ...
- poj 2594 Treasure Exploration(最小路径覆盖+闭包传递)
http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS Memory Limit: 65536K Total ...
- POJ 2594 Treasure Exploration(最小路径覆盖变形)
POJ 2594 Treasure Exploration 题目链接 题意:有向无环图,求最少多少条路径能够覆盖整个图,点能够反复走 思路:和普通的最小路径覆盖不同的是,点能够反复走,那么事实上仅仅要 ...
- POJ 1066 - Treasure Hunt - [枚举+判断线段相交]
题目链接:http://poj.org/problem?id=1066 Time Limit: 1000MS Memory Limit: 10000K Description Archeologist ...
- POJ Treasure Exploration 【DAG交叉最小路径覆盖】
传送门:http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS Memory Limit: 65536K To ...
- POJ 2594 —— Treasure Exploration——————【最小路径覆盖、可重点、floyd传递闭包】
Treasure Exploration Time Limit:6000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64 ...
- Poj 2594 Treasure Exploration (最小边覆盖+传递闭包)
题目链接: Poj 2594 Treasure Exploration 题目描述: 在外星上有n个点需要机器人去探险,有m条单向路径.问至少需要几个机器人才能遍历完所有的点,一个点可以被多个机器人经过 ...
- POJ 1066 Treasure Hunt(线段相交判断)
Treasure Hunt Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4797 Accepted: 1998 Des ...
- poj 1066 Treasure Hunt
http://poj.org/problem?id=1066 #include <cstdio> #include <cstring> #include <cmath&g ...
随机推荐
- 如何把一个android工程作为另外一个android工程的lib库
http://zhidao.baidu.com/question/626166873330652844 一个工程包含另一个工程.相当于一个jar包的引用.但又不是jar包反而像个package 在网上 ...
- Python win32api提取exe图标icon
转载地址: http://blog.csdn.net/gumanren/article/details/6129416 代码如下: # -*- coding: utf-8 -*- import sys ...
- 【翻译五】java-中断机制
Interrupts An interrupt is an indication to a thread that it should stop what it is doing and do som ...
- poj 1611:The Suspects(并查集,经典题)
The Suspects Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 21472 Accepted: 10393 De ...
- hdu 1517 博弈 **
博弈题: 题意:2 个人玩游戏,从 1 开始,轮流对数进行累乘,直到超过一个指定的值. 解题思路:如果输入是 2 ~ 9 ,因为Stan 是先手,所以Stan 必胜如果输入是 10~18 ,因为Oll ...
- [Linux] 取得服务器版本
1) 登录到服务器执行 lsb_release -a ,即可列出所有版本信息,例如: [root@3.5.5Biz-46 ~]# lsb_release -a LSB Version: 1.3 Dis ...
- HDU 4251 The Famous ICPC Team Again 主席树
The Famous ICPC Team Again Problem Description When Mr. B, Mr. G and Mr. M were preparing for the ...
- DOM兼容
-firstChild firstElementChild var oFirst = oUl.firstChild || oUl.firstElementChild; -lastChild la ...
- C#的Enum——枚举
枚举 枚举类型声明为一组相关的符号常数定义了一个类型名称.枚举用于“多项选择”场合,就是程序运行时从编译时已经设定的固定数目的“选择”中做出决定. 枚举类型(也称为枚举)为定义一组可以赋给变量的命名整 ...
- Android学习系列(42)--Android Studio实战技巧
使用android studio开发项目的一些问题,功能和技巧. 1. 环境 Mac OSX 10.9.5 + Android Studio 0.8.9 2. gradle项目加载超慢 这是因为gra ...