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 ...
随机推荐
- C#小知识点积累
1.sealed 修饰符 概念: C#提出了一个密封类(sealed class)的概念,帮助开发人员来解决这一问题. 密封类在声明中使用sealed 修饰符,这样就可以防止该类被其它类继承.如果试图 ...
- SJTU 1077 加分二叉树
http://acm.sjtu.edu.cn/OnlineJudge/problem/1077 题意: 设一个n个节点的二叉树tree的中序遍历为(l,2,3,…,n),其中数字1,2,3…,n为节点 ...
- java流、文件以及IO
读写文件 一个流被定义为一个数据序列.输入流用于从源读取数据,输出流用于向目标写数据. 输入流和输出流的类层次图. FileInputStream FileInputStream用于从文件中读取数据, ...
- CSS滚动插件
http://www.dowebok.com/131.html wow.js http://www.jq22.com/jquery-info499 smoove.js http://www.lanr ...
- IOS开发学习笔记027-UITableView 使用模型对象
1.模型对象 2.单组数据的显示 1.模型对象 继续优化上一个程序 上一次用到字典,但是坏处多多.这里将这些数据封装到类中. 这就是MVC中得模型,模型就是数据的显示结构 新建一个类,添加几个属性和一 ...
- selenium随笔
1.点击一个连接通常录制一个click命令,通常需要改变它到clickAndWait命令,确保案例暂停,新的页面完全被转载进来. 2.测试案例需要检查Web页的属性,需要assert和verify命令 ...
- springcloud 高可用分布式配置中心
SpringCloud教程七:高可用的分布式配置中心(SpringCloud Config) 当服务有很多 都要从服务中心获取配置时 这是可以将服务中心分布式处理 是系统具备在集群下的大数据处理 主要 ...
- http的一些知识
TCP/IP协议分层 应用层 TFP DNS DNS域名解析的过程 在浏览器DNS缓存中搜索 读取系统的hosts文件,查找其中是否有对应的ip 向本地配置的首选DNS服务器发起域名解析请求 HTTP ...
- 【bzoj1803】Spoj1487 Query on a tree III DFS序+主席树
题目描述 You are given a node-labeled rooted tree with n nodes. Define the query (x, k): Find the node w ...
- [luoguP2657] [SCOI2009]windy数(数位DP)
传送门 f[i][j]表示位数为i,第i位为j的windy数的个数 先预处理出f数组. 求的时候先算没有前导0的答案,再算位数和给定的数相同的答案. #include <cmath> #i ...