HDU 1033
http://acm.hdu.edu.cn/showproblem.php?pid=1033
这题的题干说的很绕,结合样例不难理解题意,走折线,A代表顺时针,V代表逆时针,给一个包含A和V的字符串,输出走过的点。
不难发现,不管是顺时针走还是逆时针走,x和y坐标的变化都是不一定的。而根据折线的特点我们知道单纯的向一个方向走的周期是4,沿着这个思路模拟出坐标变化就容易多了
#include <iostream>
#include <cstring>
using namespace std ;
char a[] ;
int sx,sy ;
int flag ;
int len ;
int main()
{
while(~scanf("%s",a))
{
printf("300 420 moveto\n310 420 lineto\n") ;
len=strlen(a) ;
sx=,sy= ;
flag= ;
for(int i=;i<len;i++)
{
if(a[i]=='A')
{
flag++ ;
if(flag>)
flag= ;
}
else{
flag-- ;
if(flag<)
flag= ;
}
if(flag%==)
sy-= ;
else if(flag%==)
sy+= ;
else if(flag%==)
sx+= ;
else if(flag%==)
sx-= ;
printf("%d %d lineto\n",sx,sy) ;
}
printf("stroke\nshowpage\n") ;
}
return ;
}
HDU 1033的更多相关文章
- HDU - 1033 Edge 【模拟】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1033 题意 给定一个起始点 300 420 走的第一步是 310 420 下面的每一步 都由 输入决定 ...
- hdu 1033 (bit masking, utilization of switch, '\0' as end of c string) 分类: hdoj 2015-06-15 21:47 37人阅读 评论(0) 收藏
bit masking is very common on the lower level code. #include <cstdio> #include <algorithm&g ...
- HDU 1033 - Edge
题目很水 然翻译感人 顺时针或者逆时针走,输出坐标 #include <iostream> using namespace std; ]; int p; ]={,,,-,}; ]={,,- ...
- HDU 1033(坐标移动 模拟)
题意是说有一点从(300,410)的位置出发,向右移动到(310,410)后开始转向,A 表示向顺时针转,V 表示向逆时针转,每次转向后沿当前方向前进 10 个单位, 输出其坐标,再补充一点格式上的东 ...
- HDU 1033 Edge[地图型模拟/给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°]
Edge Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- hdu 1973 Prime Path
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1973 Prime Path Description The ministers of the cabi ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
随机推荐
- 如何生成SSH key
SSH key提供了一种与GitHub通信的方式,通过这种方式,能够在不输入密码的情况下,将GitHub作为自己的remote端服务器,进行版本控制 步骤 检查SSH keys是否存在 生成新的ssh ...
- kill me heal me的链接
bilibili上的链接被和谐了,坑爹 韩剧网可以看,不过貌似不太清晰 http://www.hanjuwang.com/play/2015/1851.html 池城治愈营 http://www.bi ...
- spark SQL学习(spark连接 mysql)
spark连接mysql(打jar包方式) package wujiadong_sparkSQL import java.util.Properties import org.apache.spark ...
- 解题报告:hdu2602 Bone collector 01背包模板
2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:ppr ...
- Location对象常用知识
产品终于上线,后期主要是优化了.在开发过程中用到了很多location对象的知识,趁现在有时间先整理一下. Location 对象存储在 Window 对象的 Location 属性中,可通过wind ...
- 关于Spring中applicationContext.xml配置错误“org/springframework/transaction/interceptor/TransactionInterceptor”的问题解决
问题描述: 在配置spring的applicationContext.xml中的默认事务管理器的时候可能会出现这样的错误: Error occured processing XML 'org/spri ...
- Java网络编程学习A轮_02_抓包分析TCP三次握手过程
参考资料: https://huoding.com/2013/11/21/299 https://hpbn.co/building-blocks-of-tcp/#three-way-handshake ...
- Python实现CSV数据的读取--两种方法实现
方法一: 方法二:
- 搞懂分布式技术11:分布式session解决方案与一致性hash
搞懂分布式技术11:分布式session解决方案与一致性hash session一致性架构设计实践 原创: 58沈剑 架构师之路 2017-05-18 一.缘起 什么是session? 服务器为每个用 ...
- grub2 windows版安装
一.BIOS方式,grub2安装 查看磁盘情况 E:\grub-2.02-for-windows>wmic diskdrive list brief Caption DeviceID Model ...