题目链接

小小的模拟一下。

 #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. HTML CSS微信CSS显示一些总结

    微信显示网页是调用腾讯自带的浏览器内核,由于腾讯浏览器内核对css展示效果没有谷歌浏览器好,导致用谷歌浏览器写好的网页,放到微信页面之后,显示的效果就发生变化,所以调整css样式显得那么吃力: 1. ...

  2. windows常用命令

    打开"运行"对话框(Win+R),输入cmd,打开控制台命令窗口... 也可以通过cmd /c 命令 和 cmd /k 命令的方式来直接运行命令 注:/c表示执行完命令后关闭cmd ...

  3. HDU1502 Regular Words

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1502 思路:当只有两个数时,可以用卡特兰数做,当三个数时,没想到卡特兰数的做法.可以使用动态规划. 状态转 ...

  4. Quartz:Cron Expressions

    原文地址:http://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/crontrigger.html 注意: 位也可能是7位, ...

  5. Oracle数据库 控制文件

    一.概念控制文件的主要任务是管理数据库的状态以及描述数据库的物理结构 二.所含有的信息1.数据库名2.数据库标识符(DBID)3.数据库创建时间戳4.数据库字符集5.数据文件信息6.临时文件信息7.在 ...

  6. C# 重绘tabControl,添加关闭按钮(页签)

    C# 重绘tabControl,添加关闭按钮(页签) 调用方法 参数: /// <summary> /// 初始化 /// </summary> /// <param n ...

  7. C# DateTime时间格式转换为Unix时间戳格式

    double ntime=dateTimeToUnixTimestamp(DateTime.Now); long g1 = GetUnixTimestamp(); long g2 = ConvertD ...

  8. SQLServer 本地移动发布/订阅/分发数据库文件并更改逻辑名称和物理文件名

    -------------------------------------------------------------------------------------------------- - ...

  9. XCL-Charts图表库简要教程及常见问题

    这个Andriod图表库项目从开始至现在,热情消耗几近殆尽.还好已基本实现我想做的那些东西.趁还剩下点兴趣,把一些点非常简单的归纳一下. 所支持的图表类型: 基类                   ...

  10. Uva674 完全背包求方案数

    记忆化搜索.注意输入n的位置,否则Tle. dp[i][j]表示用前j种硬币组成i分钱时的种类数 那么状态转移方程是:dp[i][j]+=DP(i-k*v[j],j-1) #include<io ...