HDU 1033 Edge[地图型模拟/给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°]
Edge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4214 Accepted Submission(s): 2600
products that are wrapped in small packings it is necessary that the
sheet of paper containing the directions for use is folded until its
size becomes small enough. We assume that a sheet of paper is
rectangular and only folded along lines parallel to its initially
shorter edge. The act of folding along such a line, however, can be
performed in two directions: either the surface on the top of the sheet
is brought together, or the surface on its bottom. In both cases the two
parts of the rectangle that are separated by the folding line are laid
together neatly and we ignore any differences in thickness of the
resulting folded sheet.
After several such folding steps have been
performed we may unfold the sheet again and take a look at its longer
edge holding the sheet so that it appears as a one-dimensional curve,
actually a concatenation of line segments. If we move along this curve
in a fixed direction we can classify every place where the sheet was
folded as either type A meaning a clockwise turn or type V meaning a
counter-clockwise turn. Given such a sequence of classifications,
produce a drawing of the longer edge of the sheet assuming 90 degree
turns at equidistant places.
input contains several test cases, each on a separate line. Each line
contains a nonempty string of characters A and V describing the longer
edge of the sheet. You may assume that the length of the string is less
than 200. The input file terminates immediately after the last test
case.
each test case generate a PostScript drawing of the edge with commands
placed on separate lines. Start every drawing at the coordinates (300,
420) with the command "300 420 moveto". The first turn occurs at (310,
420) using the command "310 420 lineto". Continue with clockwise or
counter-clockwise turns according to the input string, using a sequence
of "x y lineto" commands with the appropriate coordinates. The turning
points are separated at a distance of 10 units. Do not forget the end
point of the edge and finish each test case by the commands stroke and
showpage.
You may display such drawings with the gv PostScript interpreter, optionally after a conversion using the ps2ps utility.
AVV
310 420 lineto
310 430 lineto
stroke
showpage
300 420 moveto
310 420 lineto
310 410 lineto
320 410 lineto
320 420 lineto
stroke
showpage
#include<bits/stdc++.h>
using namespace std; int main()
{
char s[];
while(cin>>s){
printf("300 420 moveto\n310 420 lineto\n");
int dir=,x=,y=;//1→ -1← 2↑ -2↓
for(int i=;i<strlen(s);i++)
{
switch(dir)//每次转弯后走10个单位
{
case ://→ V=左转 A=右转
if(s[i]=='V') dir=,y+=;
else dir=-,y-=;
break;
case ://↑
if(s[i]=='V') dir=-,x-=;
else dir=,x+=;
break;
case -:
if(s[i]=='V') dir=-,y-=;
else dir=,y+=;
break;
case -:
if(s[i]=='V') dir=,x+=;
else dir=-,x-=;
break;
}
printf("%d %d lineto\n",x,y);
}
printf("stroke\nshowpage\n");
}
return ;
}
模拟
HDU 1033 Edge[地图型模拟/给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°]的更多相关文章
- HDU - 1033 Edge 【模拟】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1033 题意 给定一个起始点 300 420 走的第一步是 310 420 下面的每一步 都由 输入决定 ...
- HDU 1033 - Edge
题目很水 然翻译感人 顺时针或者逆时针走,输出坐标 #include <iostream> using namespace std; ]; int p; ]={,,,-,}; ]={,,- ...
- HDU 1033
http://acm.hdu.edu.cn/showproblem.php?pid=1033 这题的题干说的很绕,结合样例不难理解题意,走折线,A代表顺时针,V代表逆时针,给一个包含A和V的字符串,输 ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- mysql学习1:数据类型:数字型,日期和时间,字符串类型(总结)
mysql数据类型:数字型,日期和时间,字符串类型 摘要 MySQL中定义数据字段的类型对数据库的优化是非常重要的: MySQL支持多种类型,大致可以分为三类,如下. 数字类型 整数:tinyint. ...
- HDU 5442 后缀自动机(从环字符串选定一个位置 , 时针或顺时针走一遍,希望得到字典序最大)
http://acm.hdu.edu.cn/showproblem.php?pid=5442 题目大意: 给定一个字符串,可理解成环,然后选定一位置,逆时针或顺时针走一遍,希望得到字典序最大,如果同样 ...
- Hdu 3294 Girls' research (manacher 最长回文串)
题目链接: Hdu 3294 Girls' research 题目描述: 给出一串字符串代表暗码,暗码字符是通过明码循环移位得到的,比如给定b,就有b == a,c == b,d == c,.... ...
- HDU 1033(坐标移动 模拟)
题意是说有一点从(300,410)的位置出发,向右移动到(310,410)后开始转向,A 表示向顺时针转,V 表示向逆时针转,每次转向后沿当前方向前进 10 个单位, 输出其坐标,再补充一点格式上的东 ...
- POJ 3344 & HDU 2414 Chessboard Dance(模拟)
题目链接: PKU:http://poj.org/problem? id=3344 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2414 Descrip ...
随机推荐
- Storm: 性能优化 (转载)
Storm 性能优化 原文地址:http://www.jianshu.com/p/f645eb7944b0 目录 场景假设 调优步骤和方法 Storm 的部分特性 Storm 并行度 Storm 消 ...
- Android开发——常见的内存泄漏以及解决方案(一)
0. 前言 转载请注明出处:http://blog.csdn.net/seu_calvin/article/details/52333954 Android的内存泄漏是Android开发领域永恒的 ...
- shell脚本杀掉指定进程下所有子进程(包括子进程的子进程)
搜索了网上好像并没有杀掉指定进程下所有子进程(包括子进程的子进程)的脚本,自己琢磨写了一版,虽说比较简单,但希望分享大家,帮助需要的人 #!/bin/sh # 递归找到进程最底层子进程并杀除. mai ...
- proguaid 混淆代码
注意:这里有一个坑.就是-ignorewarnings 他老是混淆不了,告诉你不行.其实加上这句话,就可以了. 下面贴一下代码: -injars c:/ceb_lib.jar -outjars c:/ ...
- mybatis特殊字符处理
在mybatis 的mapper.xml文件中特殊字符处理方式 仅供参考 出处:http://yaobenzhang.blog.163.com/blog/static/214395113201561 ...
- App 设计技巧
http://www.360doc.com/content/14/1120/18/21412_426730809.shtml http://veryui.diandian.com/post/2013- ...
- linux环境搭建系列之Apache ant安装步骤
前提: linux centOS6.6 64位操作系统 ROOT账号 JDK1.7 注意:JDK和Ant版本一定要是对应的,因为我的JDK是1.7版本的,所以我在官网下载的ant是1.9的 1.把安装 ...
- Python+Selenium框架设计篇之-什么是自动化测试框架
1.什么是自动化测试框架 简单来说,自动化测试框架就是由一些标准,协议,规则组成,提供脚本运行的环境.自动化测试框架能够提供很多便利给用户高效完成一些事情,例如,结构清晰开发脚本,多种方式.平台执行脚 ...
- Postgresql 查看建表语句 命令
pg_dump -U username databasename -W -s -t tablename -s, --schema-only 只转储模式, 不包括数据 -t, --table=TABLE ...
- Normal synchronous FIFO mode 和 Show-ahead synchronous FIFO mode
FIFO是先进先出,可以用fifo来处理跨时钟域的数据传输问题,用到的地方特别多,一定要搞会. 在学习调用fifo的IP核中发现有normal synchronous FIFO mode 和 Show ...