Single Round Match 695
来源:互联网 发布:速达 sqlserver未安装 编辑:程序博客网 时间:2024/06/06 00:21
第一次打Topcoder,好久没写类了,竟然在成员函数里又写了cin………
因为不熟悉竞技场的使用,也没弄明白具体形式,顺利秃了。
折腾一次,算是懂了如何参与TC的SRM了。以下为250points的题解。
给出每段位移,然后给出方向,最后从终点直线回到起点,return总距离。
如:
131
NES
return 8即可。
#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>using namespace std;class BearNSWE { public: double totalDistance (vector <int>, string);};double BearNSWE::totalDistance (vector <int> a, string dir) { int ans=0,x=0,y=0; int len=dir.length(); for (int i=0; i<len; i++) {ans+=a[i];} for (int i=0; i<len; i++) { if (dir[i]=='N') {y+=a[i];} else if (dir[i]=='S') {y-=a[i];} else if (dir[i]=='W') {x+=a[i];} else if (dir[i]=='E') {x-=a[i];} } return ans+sqrt (x*x+y*y);}
0 0
- Single Round Match 695
- 1790. Single Round Match
- 1790. Single Round Match
- Single Round Match
- Single Round Match
- Single Round Match
- Single Round Match
- Single Round Match
- Single Round Match
- Single Round Match
- Sicily 1790. Single Round Match
- Sicily 1790. Single Round Match
- Sicily 1790. Single Round Match
- NYOJ 786 Single Round Match
- Problem J Single Round Match
- Sicily 1790. Single Round Match
- Single Round Match 585 Div2 A B
- GDCPC 2008:J Single Round Match
- 定时器setInterval,setTimeout
- Linux VMnet Adapter无法启动的解决办法
- Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数
- LinearLayout android:divider属性
- 基于XMPP协议的及时通讯
- Single Round Match 695
- JNI.h文件浅析
- 抖动文字
- 【C语言】浮点数的上溢下溢
- C#生成二维码名片
- 2016腾讯android面试题
- 安卓之自定义按钮(以及shape详解)
- [HDU]5726
- 二次剩余Cipolla算法学习小记