ZR#1008
ZR#1008
解法:
直接预处理出来执行完一个完整的串可以到达的位置,然后算出重复的次数直接乘在坐标上,最后处理一下余下的部分就行了。
CODE:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long
#define N 5050
char ch[N];
int pos1,pos2,T,cnt1,cnt2,x,y;
int main() {
scanf("%s",ch + 1);
scanf("%d",&T);
int len = strlen(ch + 1);
for(int i = 1 ; i <= len ; i++) {
if(ch[i] == 'N') y++;
if(ch[i] == 'S') y--;
if(ch[i] == 'W') x--;
if(ch[i] == 'E') x++;
}
//cout<<len<< " "<<T;
//if(len > T) {
cnt1 = len / T,cnt2 = len % T;
x = cnt1 * x,y = cnt1 * y;
for(int i = 1 ; i <= cnt2 ; i++) {
if(ch[i] == 'N') y++;
if(ch[i] == 'S') y--;
if(ch[i] == 'W') x--;
if(ch[i] == 'E') x++;
}
//}
printf("%d %d\n",x,y);
//system("pause");
return 0;
}
ZR#1008的更多相关文章
- HDOJ 1008. Elevator 简单模拟水题
Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
- POJ 1008 Maya Calendar
链接:http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Subm ...
- BZOJ 1008 题解
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 7845 Solved: 3359[Submit][Status] ...
- HDU 4777 Rabbit Kingdom (2013杭州赛区1008题,预处理,树状数组)
Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 【BZOJ】1008: [HNOI2008]越狱(快速幂)
http://www.lydsy.com/JudgeOnline/problem.php?id=1008 刚开始看不会做啊,以为是dp,但是数据太大!!!所以一定有log的算法或者O1的算法,,,,还 ...
- PAT (Top Level) Practise 1008 Airline Routes(Tarjan模版题)
1008. Airline Routes (35) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a ...
- PAT乙级 1008. 数组元素循环右移问题 (20)
1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数,在不允 ...
- [ZOJ 1008]Gnome Tetravex (dfs搜索 + 小优化)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目大意:给你n*n的矩阵,每个格子里有4个三角形,分别是 ...
随机推荐
- Redis安装--CentOS7上安装Redis
echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 1.R ...
- iOS - 适配iOS 11
http://www.10tiao.com/html/330/201707/2653579210/1.html 存档 导语:iOS 11 为整个生态系统的 UI 元素带来了一种更加大胆.动态的新风格. ...
- javascript创建一个基于对象的栈结构
上篇博客介绍了基于数组创建一个栈,这是用对象创建一个栈 s1.声明一个Stack类 class Stack { constructor() { this.count = 0; this.items = ...
- Springboot项目统一异常处理
Springboot项目统一异常处理 一.接口返回值封装 1. 定义Result对象,作为通用返回结果封装 2. 定义CodeMsg对象,作为通用状态码和消息封装 二.定义全局异常类 三.定义异常处理 ...
- C++中头文件与源文件的作用详解
一.C++ 编译模式 通常,在一个 C++ 程序中,只包含两类文件―― .cpp 文件和 .h 文件.其中,.cpp 文件被称作 C++ 源文件,里面放的都是 C++ 的源代码:而 .h 文件则被称作 ...
- java web编程 servlet读取配置文件参数
新建一个servlet. 然后在web.xml文件里面自动帮助你创建好了<servlet-name><servlet-class><servlet-mapping> ...
- zabbix-proxy及ELK
1.添加tomcat监控模版 yum install java-1.8.0-openjdk tomcat-webapps tomcat-admin-webapps tomcat-docs-webapp ...
- 采用MySQL-MMM做DB高可用时,遇到的一个小坑
一.服务器分布 二.MySQL-MMM 配置 (1).公共配置[所有DB节点:Master1.Master2.Slave1.Slave2 Monitor节点] # vim /etc/mysql ...
- Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapt ...
- 配置jdk和环境变量
1.官网下载jdk1.8,默认安装即可 2.JAVE_HOME:jdk安装目录 path:C:;%JAVA_HOME%\bin; C:;%JAVA_HONE%\jre\bin;(当dos界面输入命令 ...