杭电ACM OJ 1033 Edge 本题考查英文过了6级没有和谷歌翻译的使用

Edge

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4019    Accepted Submission(s): 2490


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.

杭电ACM OJ 1033 Edge 本题考查英文过了6级没有和谷歌翻译的使用

 

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
翻译:这一题的英文坑的么简直就不谈了。不过还是开着谷歌翻译秒懂了。嘿嘿。
我们预定义了两个出发点:
300 420 moveto
310 420 lineto
就是从300 420 移动到310 420
接下来就要开始转弯了。
看上面那个AVV序列。当前读到A,那就是右转,我们就到了310 410(参照上面那个图下半部分)。水平过去第一个拐角,因为是A,所以右转。
再是V,左转(因为你当前方向是朝下的,左转自然就是向右了)。以此类推。
代码:
package ACM1000_1099;

public class Edge1033 {
    void calculate() {
        System.out.println("300 420 move to");
        System.out.println("310 420 line to");

        char[] a = {'A','V','V'};

        String[] direction = new String[4];
        direction[0] = "top";
        direction[1] = "bottom";
        direction[2] = "left";
        direction[3] = "right";

        String current = direction[3];
        int currentX = 310;
        int currentY = 420;

        for (int i = 0; i < a.length; i ++) {
            switch (current) {
                case "top":
                    if (a[i] == 'A') {
                        current = direction[3];
                        currentX += 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    } else {
                        current = direction[2];
                        currentX -= 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    }
                    break;
                case "bottom":
                    if (a[i] == 'A') {
                        current = direction[2];
                        currentX -= 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    } else {
                        current = direction[3];
                        currentX += 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    }
                    break;
                case "left":
                    if (a[i] == 'A') {
                        current = direction[0];
                        currentY += 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    } else {
                        current = direction[1];
                        currentY -= 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    }
                    break;
                case "right":
                    if (a[i] == 'A') {
                        current = direction[1];
                        currentY -= 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    } else {
                        current = direction[0];
                        currentY += 10;
                        System.out.println(currentX + " " + currentY + " " + "line to");
                    }
                    break;
            }
        }
    }

    public static void main(final String[] args) throws Exception {
        Edge1033 e = new Edge1033();
        e.calculate();
    }
}


看了通过率,看来接下来有一大波水题要袭来,我的心情是崩溃的。
杭电ACM OJ 1033 Edge 本题考查英文过了6级没有和谷歌翻译的使用
2017-10-27 12:46开始写第一篇
到现在
2017-12-4 1:33
用时
38天。4197访问。1000积分。4级。(今晚为了凑够1000分刷了好几个水题(脸都不要了!))
记录一下。
接下来一个月,不是那么急着冲刺3000分和5级,没有意义。而是应该尽快领悟所有rv的源码,进入ndk世界,复习(预习)期末考试。