题目英文太多,简单翻译了一下:
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[][] = {{, }, {, }, {-, }, {, -}};
  8. int a_dir[][] = {{, }, {, -}, {-, }, {, }};
  9.  
  10. int setnextdir(int dirs[][], int dir[]) {
  11. int i, index = -;
  12.  
  13. for (i=; i<; ++i)
  14. if (dirs[i][]==dir[] &&dirs[i][]==dir[]) {
  15. index = i;
  16. break;
  17. }
  18.  
  19. if (index >= ) {
  20. index = (index+) & ;
  21. dir[] = dirs[index][];
  22. dir[] = dirs[index][];
  23. return ;
  24. }
  25. return ;
  26. }
  27.  
  28. int main() {
  29. int pos[];
  30. int dir[];
  31. int i;
  32.  
  33. while (scanf("%s", buf) != EOF) {
  34. getchar();
  35. // initial
  36. pos[]=; pos[]=;
  37. dir[]=; dir[]=;
  38. printf("300 420 moveto\n");
  39. pos[] += dir[];
  40. pos[] += dir[];
  41. printf("%d %d lineto\n", pos[], pos[]);
  42.  
  43. for (i=; i<(int)(strlen(buf)); ++i) {
  44. if (buf[i] == 'A')
  45. setnextdir(a_dir, dir);
  46. else
  47. setnextdir(v_dir, dir);
  48. pos[] += dir[];
  49. pos[] += dir[];
  50. printf("%d %d lineto\n", pos[], pos[]);
  51. }
  52.  
  53. printf("stroke\nshowpage\n");
  54. }
  55.  
  56. return ;
  57. }

【HDOJ】1033 Edge的更多相关文章

  1. 【CODEVS】1033 蚯蚓的游戏问题

    [算法]网络流-最小费用最大流(费用流) [题解]与方格取数2类似 在S后添加辅助点S_,限流k 每条边不能重复走,限流1 #include<cstdio> #include<alg ...

  2. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  3. 【hihoCoder】1033: 交错和

    初探数位dp 介绍了数位类统计的基础知识.以下列出其中的基础点: 基本问题 统计在区间[l, r]中满足条件的数的个数 思路 1. [l, r] 将问题转换为 在[0, r]中满足条件的个数 - 在[ ...

  4. 【wikioi】1033 蚯蚓的游戏问题(费用流)

    http://wikioi.com/problem/1033/ 这题也是很水的费用流啊,同之前那题一样,拆点然后建边,容量为1,费用为点权.然后建个源连第一行每个点,容量为1,费用为0,然后最后一行每 ...

  5. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  6. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  7. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

  8. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

  9. 【HDOJ】【3415】Max Sum of Max-K-sub-sequence

    DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...

随机推荐

  1. Linux中的版本控制---diff和patch命令

    一.构造两个用于测试的文件 hello.txt: world.txt: 二.用diff命令比较两个文本文件的差异 对这个两个文本文件执行diff‘命令,并通过输出重定向,将差异保存在diff.txt文 ...

  2. ###Markdown初步学习

    Markdown学习/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) *//* Author: Nicolas Hery - ...

  3. 工作“触雷”经历与总结--记博弈论的应用

    工作三年,职场受挫.一些值得说或者不值得说的事情,也懒得去记录.无奈,更多时无奈.内心的骄傲或者自负也不值得炫耀.天生骄傲,或者也只是自身内心的呐喊.毕竟,骄傲的人也不会说出来,搞的好像是有点似得. ...

  4. android测试的相关概念以及单元测试

    1.测试的相关概念  1.根据是否知道源代码分类: 黑盒测试: a - b - c  边值测试    白盒测试: 根据源代码写测试方法 或者 测试用例; 2.根据测试的粒度分类: 方法测试:写完一个方 ...

  5. 某deed笔试题

    1.  删除ra,输入s,然后从前往后扫,遇到直接删除,O(n),算水题吧. 2. 矩阵乘法,看完题,感觉这么简单,估计有什么套路,仔细再读一遍,发现真是水题,50*50*50=125000,在2s时 ...

  6. 九度OJ 1500 出操队形 -- 动态规划(最长上升子序列)

    题目地址:http://ac.jobdu.com/problem.php?pid=1500 题目描述: 在读高中的时候,每天早上学校都要组织全校的师生进行跑步来锻炼身体,每当出操令吹响时,大家就开始往 ...

  7. Python3 面向对象 高级编程

    正常情况下,当我们定义了一个class,创建了一个class的实例后,我们可以给该实例绑定任何属性和方法,这就是动态语言的灵活性.  class Student(object): pass 然后,尝试 ...

  8. Unity3D--学习太空射击游戏制作(一)

    近期买了本书在学习一些Unity3D的东西,在了解了Unity3D工具的基本面板后开始学习一个太空射击游戏的开发过程. 首先下载一个关于本游戏的资源文件,(百度云下载地址:http://pan.bai ...

  9. CoreText实现图文混排之点击事件-b

    CoreText实现图文混排之点击事件 主要思路 我们知道,CoreText是基于UIView去绘制的,那么既然有UIView,就有 -(void)touchesBegan:(NSSet<UIT ...

  10. Mongodb FAQ 存储(storage)篇

    1.什么是内存映射文件(memory mapped files)? 内存映射文件是操作系统通过调用函数mmap()创建的一个放在内存中的一个数据文件.这种文件可以当做一个从零开始的内存或者数组,你可以 ...