题目链接

小小的模拟一下。

 #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!的更多相关文章

  1. poj 2594 Treasure Exploration (二分匹配)

    Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 6558   Accepted: 2 ...

  2. poj 2594 Treasure Exploration(最小路径覆盖+闭包传递)

    http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total ...

  3. POJ 2594 Treasure Exploration(最小路径覆盖变形)

    POJ 2594 Treasure Exploration 题目链接 题意:有向无环图,求最少多少条路径能够覆盖整个图,点能够反复走 思路:和普通的最小路径覆盖不同的是,点能够反复走,那么事实上仅仅要 ...

  4. POJ 1066 - Treasure Hunt - [枚举+判断线段相交]

    题目链接:http://poj.org/problem?id=1066 Time Limit: 1000MS Memory Limit: 10000K Description Archeologist ...

  5. POJ Treasure Exploration 【DAG交叉最小路径覆盖】

    传送门:http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K To ...

  6. POJ 2594 —— Treasure Exploration——————【最小路径覆盖、可重点、floyd传递闭包】

    Treasure Exploration Time Limit:6000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64 ...

  7. Poj 2594 Treasure Exploration (最小边覆盖+传递闭包)

    题目链接: Poj 2594 Treasure Exploration 题目描述: 在外星上有n个点需要机器人去探险,有m条单向路径.问至少需要几个机器人才能遍历完所有的点,一个点可以被多个机器人经过 ...

  8. POJ 1066 Treasure Hunt(线段相交判断)

    Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4797   Accepted: 1998 Des ...

  9. poj 1066 Treasure Hunt

    http://poj.org/problem?id=1066 #include <cstdio> #include <cstring> #include <cmath&g ...

随机推荐

  1. 设计模式学习之适配器模式(Adapter,结构型模式)(14)

    参考链接:http://www.cnblogs.com/zhili/p/AdapterPattern.html一.定义:将一个类的接口转换成客户希望的另一个接口.Adapter模式使得原本由于接口不兼 ...

  2. Genymotion刷入谷歌应用市场以及获取root权限

    Genymotion刷入谷歌应用市场以及获取root权限 - 推酷http://www.tuicool.com/articles/rEV3aa6 刷入gapp, arm框架,supersu的包要注意, ...

  3. Windows 8使用这半年(企业版)

    2014-06-23 硬件:thinkpad e430c core i5-3210m 4g/500g 1.Windows 8出现开机引导问题 主要开机的时候提示缺少引导文件,按ctrl+alt+del ...

  4. 如何在java中使用别人提供的jar包进行导入,编译,运行

    一步一步往前走, 现在折分! JAR包即为上篇文章的东东. 测试JAVA文件. package com.security; import com.security.AESencrp; /** * 实现 ...

  5. MYSQL建表语法(主键,外键,联合主键)

    在看<Learning SQL>第二版, 慢慢打实SQL的基础. 建表一: ), lname ), gender ENUM(), city ), state ), country ), p ...

  6. js中ascii码的转换

    今天在把原来用C写的程序移植到javascript上,但是有个地方一直调不通,后来才发现是js奇葩的字符处理出的问题.c中使用的字符处理比如加上一个字符值强制转换一下,在js中就行不通了. 但是js提 ...

  7. Java学习随笔1:Java是值传递还是引用传递?

    Java always passes arguments by value NOT by reference. Let me explain this through an example: publ ...

  8. Linux学习笔记(9)Linux常用命令之关机重启命令

    (1)shutdown shutdown命令用于关机重启,其语法格式为: shutdown [选项] 时间 其中,-c选项表示取消前一个设置的shutdown命令,-h命令表示关机,-r命令表示重启 ...

  9. Android自动化测试之Monkey Test(一)

    Monkey是什么 Monkey是可以运行在模拟器里或实际设备中的程序.它向系统发送伪随机的用户事件流(如按键输入.触摸屏输入.手势输入等),实现对正在开发的应用程序进行压力测试.   Monkey简 ...

  10. 记录Android Studio项目提交到github上的出错处理

    首先是按照网上的教程进行了一次提交,具体见http://web.gxzj.com.cn/News.aspx?id=325505 记得当时出现过这个错误Can't connect to reposito ...