Edge(待定)
来源:互联网 发布:漱口水 酒精 知乎 编辑:程序博客网 时间:2024/05/16 13:04
Edge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3805 Accepted Submission(s): 2373
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<stdio.h>#include<string.h>int main(){char str[201];while(scanf("%s",str)!=EOF){int len=strlen(str);int x=310;int y=420;int t=2;printf("300 420 moveto\n");printf("310 420 lineto\n");for(int i=0;i<len;i++){if(str[i]=='V'){t++;if(t==5)t=1;}if(str[i]=='A'){t--;if(t==0)t=4;}if(t==1)y-=10;if(t==2)x+=10;if(t==3)y+=10;if(t==4)x-=10;printf("%d %d lineto\n",x,y);}printf("stroke\nshowpage\n");}}
阅读全文
0 0
- Edge(待定)
- 网络通信(待定)
- 编程题(待定)
- 待定
- 待定
- 待定
- 待定
- Java基础题(待定)
- Javaweb面试题(待定)
- 前端面试题(待定)
- 数据库面试题(待定)
- 多线程面试题(待定)
- spring框架面试题(待定)
- 数据结构与算法面试题(待定)
- Java IO面试题(待定)
- EDGE
- Edge
- EDGE
- 流畅的Python
- HRBUST
- lwip 中tcp能与内网通信,但不能和外网通信的解决方法
- 《剑指offer》字符流中第一个不重复的字符
- HDU5938+贪心+(2016年中国大学生程序设计竞赛(杭州))
- Edge(待定)
- mongo driver类加载导致的错误
- Emmagee app性能测试工具使用教程(转)
- 秒拍社招面经
- 利用IO流对文件进行分割和无损还原合并
- [Baltic2004]BZOJ 3916 friends
- Unity3D使用WWW类和协程完成图片、视频下载播放
- 羽毛球套路简介
- python中的字典及注意事项