HDU 1033 Edge
来源:互联网 发布:mac广州专柜地址查询 编辑:程序博客网 时间:2024/04/29 18:08
题目看到蛋碎也没看懂啊~
Edge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1242 Accepted Submission(s): 821
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.
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.
You may display such drawings with the gv PostScript interpreter, optionally after a conversion using the ps2ps utility.
Sample Input
VAVV
Sample Output
300 420 moveto310 420 lineto310 430 linetostrokeshowpage300 420 moveto310 420 lineto310 410 lineto320 410 lineto320 420 linetostrokeshowpage
#include <iostream>using namespace std;int f[4][2] = {0,10,10,0,0,-10,-10,0};void move(int &x, int &y, char c, int &s){int u;switch (s){case 0: if (c=='V') u = 0, s = 1; else u = 2, s = 3; break;case 1: if (c=='V') u = 3, s = 2; else u = 1, s = 0; break;case 2: if (c=='V') u = 2, s = 3; else u = 0, s = 1; break;case 3: if (c=='V') u = 1, s = 0; else u = 3, s = 2; break;}x += f[u][0];y += f[u][1];}int main(){char c[300];int i, k;while (~scanf("%s", c)){k = strlen(c);printf("300 420 moveto\n310 420 lineto\n");int x = 310, y = 420, s = 0;for (i=0;i<k;++i){move(x, y, c[i], s);printf("%d %d lineto\n", x, y);}printf("stroke\nshowpage\n");}return 0;}
- HDU 1033 Edge 旋转
- HDU 1033 Edge
- hdu - 1033 - Edge
- hdu 1033 Edge
- hdu 1033 Edge
- HDU 1033 Edge
- HDU 1033 Edge
- HDU 1033 Edge
- HDU 1033 Edge 模拟
- HDU 1033 Edge
- hdu 1033 Edge
- HDU 1033 Edge
- HDU 1033 Edge
- hdu 1033——Edge
- 杭电 HDU 1033 Edge
- HDU 1033 Edge(水题)
- HDU 1033 Edge 图论简单题
- HDU-1033-Edge(C++ && 简单模拟 && 题意恶心)
- get network hotplugging working on Ubuntu 12.04 LTS
- 13、EL表达式
- Android碰撞检测——圆形检查
- C++空类的默认成员函数总结
- Structs2学习小结
- HDU 1033 Edge
- 解决win7下cisco vpn的Reason 442问题
- c语言函数调用详细过程
- Struts2+freemarker开发搭建
- 汉字转换拼音字头原理实践
- C/C++笔试题
- 简单的thread_pool代码
- win7 64位旗舰版 安装 cisco VPN client ,无法启动
- official software version number management