Hdu-1033-edge (c + + && simple simulation && test instructions nausea)

Source: Internet
Author: User

EdgeTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 2314 Accepted Submission (s): 1477


Problem Descriptionfor products that's wrapped in small packings it's necessary that the sheet of paper containing the Directions for use are folded until its size becomes small enough. We assume that a sheet of paper are rectangular and only folded along lines parallel to its initially shorter edge. The act of folding along such a line, however, can is performed in both directions:either the surface on the top of the SH Brought together, or the surface on its bottom. In both cases the parts of the rectangle that is separated by the folding line is laid together neatly and we ignore Any differences in thickness of the resulting folded sheet.
After several such folding steps has been performed we may unfold the sheet again and take a look at it longer edge hold ing the sheet so this it appears as a one-dimensional curve, actually a concatenation of line segments. If we move along this curve with a fixed direction we can classify every place where the sheet is folded as either type a M Eaning 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-degree turns at EQ Uidistant places.

Inputthe 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 the length of the string are less than 200. The input file terminates immediately after the last Test case.

Outputfor each test case generate a PostScript to drawing of the edge with commands placed on separate lines. Start every drawing at the coordinates (+ 420) with the command "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" command s with the appropriate coordinates. The turning points is separated at a distance of ten units. The forget the end point of the edge and the finish each test case by the commands stroke and showpage.

You could display such drawings with the GV PostScript interpreter, optionally after a conversion using the Ps2ps utility.



Sample Input
Vavv

Sample Output
420 moveto310 420 lineto310 430 linetostrokeshowpage300 420 moveto310 420 lineto310 410 lineto320 410 lineto320 420 li Netostrokeshowpage

Sourceuniversity of Ulm Local Contest 2003
Recommendwe carefully selected several similar problems for you:1035 1036 1039 1032 1062

Three days did not write, the head is a little rusty, congratulate my friend Lao Zhao become the Northeast division of ACM Official team! Bloggers, of course, are happy for him! Helpless level is too poor, can not fight with it, so I have time to do the problem is good, there is a sentence is not always said, their choice of the road! On my knees to go, even if I was a formal game also participated in Slag slag, but this AC heart, never give up!

Next, today's topic, the question person is simply disgusting, (obviously is a water problem must make so big on? I think even if the English is very good people, see this problem will be very laborious, not to say, English bad person (for example I), said a circle, test instructions explanation of vague, what is called concise, I was drunk! What's inside a is clockwise, V is counterclockwise, I did not read for 30 minutes to understand!
So the test instructions is: it gives you a starting point and the direction of the first draw line, the first starting point is (300,420), the first draw line direction to the right, so every time you have to output: 420 moveto310 420 LineTo and then back then according to your input a, V to re-draw the line, remember that a is toward the right V is to the left
Then the only difficulty is to use Dir to control the east direction of the decision, Dir's period is 4
A toward the right, V to the left #include<iostream> #include <cstdio> #include <cstring>using namespace std; #define LEN    300int Main () {char cmd[len];        while (scanf ("%s", cmd)!=eof) {int I, j, Len;        int x, y, dir;        dir = 0;        x = 310;        y = 420;        Len = strlen (cmd);        printf ("420 moveto\n");        printf ("310 420 lineto\n");                for (i=0;i<len;i++) {if (' V ' ==cmd[i]) {switch (dir) {                    Case 0:y+=10;                Break                    Case 1:x+=10;                Break                    Case 2:y-=10;                Break                    Case 3:x-=10;                Break                } dir= (dir+3)%4;            printf ("%d%d lineto\n", x, y);                } else if (' A ' ==cmd[i]) {switch (dir) {Case 0:y-=10;                Break                    Case 1:x-=10;                Break                    Case 2:y+=10;                Break                    Case 3:x+=10;                Break                dir = (dir+1)%4;            printf ("%d%d lineto\n", x, y);        }} printf ("stroke\n");    printf ("showpage\n"); }}



Hdu-1033-edge (c + + && simple simulation && test instructions nausea)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.