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

  1. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  2. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  3. POJ 1008 Maya Calendar

    链接:http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

  4. BZOJ 1008 题解

    1008: [HNOI2008]越狱 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7845  Solved: 3359[Submit][Status] ...

  5. HDU 4777 Rabbit Kingdom (2013杭州赛区1008题,预处理,树状数组)

    Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  6. 【BZOJ】1008: [HNOI2008]越狱(快速幂)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1008 刚开始看不会做啊,以为是dp,但是数据太大!!!所以一定有log的算法或者O1的算法,,,,还 ...

  7. PAT (Top Level) Practise 1008 Airline Routes(Tarjan模版题)

    1008. Airline Routes (35) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a ...

  8. PAT乙级 1008. 数组元素循环右移问题 (20)

    1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数,在不允 ...

  9. [ZOJ 1008]Gnome Tetravex (dfs搜索 + 小优化)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目大意:给你n*n的矩阵,每个格子里有4个三角形,分别是 ...

随机推荐

  1. pycharm从本地离线添加模块

    豆瓣的源: http://pypi.douban.com/simple pip install matplotlib -i http://pypi.douban.com/simple --truste ...

  2. CSS标签选择器&类选择器

    基本选择器包括标签选择器.类选择器和ID选择器三类,其他选择器都是在这三类选择器的基础上组合形成 ##标签选择器 示例: <style type="text/css"> ...

  3. Fortify漏洞之Dynamic Code Evaluation: Code Injection(动态脚本注入)和 Password Management: Hardcoded Password(密码硬编码)

    继续对Fortify的漏洞进行总结,本篇主要针对  Dynamic Code Evaluation: Code Injection(动态脚本注入) 和 Password Management: Har ...

  4. 安恒pwn魔法

    魔法这是比较基础的一道栈溢出: 首先看下开启的防护机制 Checksec magicc发现只有nx防护 我们载入ida发现溢出点 Buf实际溢出空间为0x16,构造exp import time fr ...

  5. maven cmd 命令

    1. mvn clean install :重新清理打包 2.详见:https://www.cnblogs.com/lukelook/p/11298168.html mvn  versions:upd ...

  6. iview 标题内边距过大; 调整iview 单元格内边距、行高;

    1css代码: /*调整table cell间隔和行高*/ .ivu-table-cell { padding-left: 1px; padding-right: 1px; } .ivu-table- ...

  7. 批量改主机名报错:Address 192.168.43.117 maps to bogon, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!

    ssh连接批量修改主机名报出以下提示: [root@bqh-nfs- ~]# vim modfilyhostname.sh [root@bqh-nfs- ~]# sh modfilyhostname. ...

  8. Django——Xadmin中的功能

    app_label 功能 如果不在标准models.py里面定义model,则必须指定这个model归属于哪个app. 使用 app_label = 'oms' actions 功能 Action插件 ...

  9. k8s 如何支持私有镜像

    k8s如何支持私有镜像 实现无密钥编排 kubectl create secret docker-registry regsecret --docker-server=registry.cn-shen ...

  10. Please provide compiled classes of your project with sonar.java.binaries property

    是因为一个jar包版本的原因,sonar-java-plugin-5.1.0.13090.jar 需要降级 https://repo.maven.apache.org/maven2/org/sonar ...