zoukankan      html  css  js  c++  java
  • 【HDOJ】1033 Edge

    题目英文太多,简单翻译了一下:
    1. 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.
        对于那些使用小包包裹的产品,包含所使用方向的包装纸应当折叠起来并且足够小。    
    2. We assume that a sheet of paper is rectangular and only folded along lines parallel to its initially shorter edge.
        我们假定包装纸是长方形,并且仅可以沿着平行于初始较短边对折。
    3. 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.
        折叠的动作尽管只能沿着一条线,但是却可以沿着两个方向进行:或者将包装纸的顶部折叠在一起,或者将底部折叠在一起。
    4. 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.
        两种情况下,长方形都被折叠线分成两部分并且整齐的叠放在一起,这里我们忽略折叠包装纸的厚度差异。
    5. 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.
        在经过几次折叠后,我们重新打开包装纸并且观察包装纸的较长边的边缘,它看起来像一维曲线,事实上是级联的线段。
    6. 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.
        如果我们沿着曲线的固定方向移动,我们可以将每个折叠区域分类,沿顺时针方向为A,逆时针方向为V。
    7. Given such a sequence of classifications, produce a drawing of the longer edge of the sheet assuming 90 degree turns at equidistant places.
        给定这样一个分类序列,在包装纸等距的地方沿给定方向转90度然后画线。
    其实非常简单,程序如下:

     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 #define MAXNUM 205
     5 char buf[MAXNUM];
     6 
     7 int v_dir[4][2] = {{10, 0}, {0,  10}, {-10, 0}, {0, -10}};
     8 int a_dir[4][2] = {{10, 0}, {0, -10}, {-10, 0}, {0,  10}};
     9 
    10 int setnextdir(int dirs[4][2], int dir[2]) {
    11     int i, index = -1;
    12 
    13     for (i=0; i<4; ++i)
    14         if (dirs[i][0]==dir[0] &&dirs[i][1]==dir[1]) {
    15             index = i;
    16             break;
    17         }
    18 
    19     if (index >= 0) {
    20         index = (index+1) & 3;
    21         dir[0] = dirs[index][0];
    22         dir[1] = dirs[index][1];
    23         return 1;
    24     }
    25     return 0;
    26 }
    27 
    28 int main() {
    29     int pos[2];
    30     int dir[2];
    31     int i;
    32 
    33     while (scanf("%s", buf) != EOF) {
    34         getchar();
    35         // initial
    36         pos[0]=300; pos[1]=420;
    37         dir[0]=10;  dir[1]=0;
    38         printf("300 420 moveto
    ");
    39         pos[0] += dir[0];
    40         pos[1] += dir[1];
    41         printf("%d %d lineto
    ", pos[0], pos[1]);
    42 
    43         for (i=0; i<(int)(strlen(buf)); ++i) {
    44             if (buf[i] == 'A')
    45                 setnextdir(a_dir, dir);
    46             else
    47                 setnextdir(v_dir, dir);
    48             pos[0] += dir[0];
    49             pos[1] += dir[1];
    50             printf("%d %d lineto
    ", pos[0], pos[1]);
    51         }
    52 
    53         printf("stroke
    showpage
    ");
    54     }
    55 
    56     return 0;
    57 }
    View Code
  • 相关阅读:
    SuperSocket 日志接口
    SuperSocket 中的日志系统
    supersocket为动态命令增加命令过滤器
    如何让 jQuery Mobile 不显示讨厌的 loading 界面
    腾讯推出微信公众平台企业服务平台风铃
    微信公众平台开发(47)公交查询
    微信公众平台开发(48)星座运势
    微信公众平台开发(45)食物营养及热量查询
    微信公众平台开发(46)在线电影/移动影院
    微信公众平台开发(44)历史上的今天
  • 原文地址:https://www.cnblogs.com/bombe1013/p/3611801.html
Copyright © 2011-2022 走看看