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 ...
随机推荐
- Eclipse中怎么设置Add cast to Clazz 快捷键
方法如下:window => preferences => 搜索keys => 然后点击进去,搜索add cast => 看到如图所示Quick Fix , 点击进去 => ...
- Pyqt 中__init__(self,parent==None) parent理解
参考: 在PyQt中,所有class都是从QObject派生而来,QWidget对象就可以有一个parent.这种parent-child关系主要用于两个方面: 没有parent的QWidget类被认 ...
- 时间:UTC时间、GMT时间、本地时间、Unix时间戳
转自:http://blog.csdn.net/u012102306/article/details/51538574 1.UTC时间 与 GMT时间 我们可以认为格林威治时间就是时间协调时间(GMT ...
- HR外包系统 - 工资计算-几种常见账单计算规则
01-正常工资计税 (包括同一月多地计税方式) 02-年终奖计税 (包括可分批发放,但计税总额不变) 按工资 除以月份,看落在那个计税区间,获取税率和扣除数,再用总额*税率-扣除数,要考虑当月工资如 ...
- Android入门开发之SD卡读写操作(转)
SD卡的读写是我们在开发android 应用程序过程中最常见的操作.下面介绍SD卡的读写操作方式: 1. 获取SD卡的根目录 String sdCardRoot = Environment.getE ...
- 解决"System.AccessViolationException”类型的未经处理的异常在 未知模块(IIS Worker Process 已停止工作)导致无法连接远程数据库的问题
解决方法: 用管理员身份运行CMD,输入netsh winsock reset并回车(注意,必须是已管理员身份运行,这个重置LSP连接)
- C#联通新版验证码识别的实现
以前写了篇 联通充值卡自动充值的实现,最近发现联通官网改版了,随便看了下发现新版的验证码和以前的不同,发了点时间研究了下他的识别码,它现在的验证码如下 现在将识别步骤说下 1,转换灰度图片 2,清除2 ...
- loj 1316(spfa预处理+状压dp)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=27024 题意:求0-(n-1)的经过最多的标记的点的最短路. 思路 ...
- ado.net增删改查操作
ado.net是数据库访问技术将数据库中的数据,提取到内存中,展示给用户看还可以将内存中的数据写入数据库中去 并不是唯一的数据库访问技术,但是它是最底层最基础的数据库访问技术 使用ado.net对数据 ...
- loadrunner生成随机数
loadrunner生成随机数一: 对网站注册进行压力测试时,需要对注册的用户名进行参数化,因为可以会用到大量的测试数据,所以选择通过生成随机数来进行参数化.最开始用loadrunner自带的参数随机 ...