# HDU1033 Edge

## 题目

http://acm.hdu.edu.cn/showproblem.php?pid=1033

### Problem Description

For 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

The 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.

### Output

For 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.

### Sample Input

V
AVV


### Sample Output

300 420 moveto
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


### Source

University of Ulm Local Contest 2003

## 要点

• Top 上表面 Bottom 下表面

• 前面罗里吧嗦的引子只是阐明了这样个道理

把一张纸多次重合对折，展开后有呈#状的折痕。然后就可以用A V来描述任意折痕边缘的路径了

做题的流程就是描述画图的过程

事实上后来查了下 MoveToLineTo本来就是绘图函数

moveto（50,50）是将画笔移动到参数指定的坐标（50,50）
lineto（150,50）是从画笔的当前位置绘制一条直线到参数给的坐标（150,50）

由此便有了 折 的图形了

## 自己家的代码

#include <iostream>
#include <stdio.h>
using namespace std;
enum Trend {U,D,L,R}; //方向
struct Point
{
int x;
int y;
} p;
void lineto()
{
printf("%d %d lineto\n",p.x,p.y);
}
int main()
{
Trend t;
char command;
//trend a = trend::d;
while (~scanf("%s",command))
{
int i;
printf("300 420 moveto\n");
p.x=310;
p.y=420;
t=R;
lineto();
for (i=0; command[i]!='\0'; i++)
{
if (command[i]=='A')
{
switch (t)
{
case R:
t=D;
p.y-=10;
break;
case L:
t=U;
p.y+=10;
break;
case U:
t=R;
p.x+=10;
break;
case D:
t=L;
p.x-=10;
break;
}
}
else if (command[i]=='V')
{
switch (t)
{
case R:
t=U;
p.y+=10;
break;
case L:
t=D;
p.y-=10;
break;
case U:
t=L;
p.x-=10;
break;
case D:
t=R;
p.x+=10;
break;
}
}
lineto();
}
cout << "stroke" << endl << "showpage" << endl;
}
return 0;
}



## p.s

• 现在每次看到水题两个字，感受到深深的恶意
• 看不懂题意真的特难受，劝退法宝
• ACM也是阅读理解题
• 从现在开始我这个p.s阶段是基本上少不了的了，每次看其他大佬的解题报告心中真是。。反正就将这个风格延续下去，做成我心目中应当呈现的样子
• 就这样，从看到题，到理解再到写这篇博文已经过去了一个半小时。消磨时间利器。
posted @ 2019-01-22 11:38  StarSpark0  阅读(67)  评论(0编辑  收藏