【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度然后画线。
其实非常简单,程序如下:
#include <stdio.h>
#include <string.h> #define MAXNUM 205
char buf[MAXNUM]; int v_dir[][] = {{, }, {, }, {-, }, {, -}};
int a_dir[][] = {{, }, {, -}, {-, }, {, }}; int setnextdir(int dirs[][], int dir[]) {
int i, index = -; for (i=; i<; ++i)
if (dirs[i][]==dir[] &&dirs[i][]==dir[]) {
index = i;
break;
} if (index >= ) {
index = (index+) & ;
dir[] = dirs[index][];
dir[] = dirs[index][];
return ;
}
return ;
} int main() {
int pos[];
int dir[];
int i; while (scanf("%s", buf) != EOF) {
getchar();
// initial
pos[]=; pos[]=;
dir[]=; dir[]=;
printf("300 420 moveto\n");
pos[] += dir[];
pos[] += dir[];
printf("%d %d lineto\n", pos[], pos[]); for (i=; i<(int)(strlen(buf)); ++i) {
if (buf[i] == 'A')
setnextdir(a_dir, dir);
else
setnextdir(v_dir, dir);
pos[] += dir[];
pos[] += dir[];
printf("%d %d lineto\n", pos[], pos[]);
} printf("stroke\nshowpage\n");
} return ;
}
【HDOJ】1033 Edge的更多相关文章
- 【CODEVS】1033 蚯蚓的游戏问题
[算法]网络流-最小费用最大流(费用流) [题解]与方格取数2类似 在S后添加辅助点S_,限流k 每条边不能重复走,限流1 #include<cstdio> #include<alg ...
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
- 【hihoCoder】1033: 交错和
初探数位dp 介绍了数位类统计的基础知识.以下列出其中的基础点: 基本问题 统计在区间[l, r]中满足条件的数的个数 思路 1. [l, r] 将问题转换为 在[0, r]中满足条件的个数 - 在[ ...
- 【wikioi】1033 蚯蚓的游戏问题(费用流)
http://wikioi.com/problem/1033/ 这题也是很水的费用流啊,同之前那题一样,拆点然后建边,容量为1,费用为点权.然后建个源连第一行每个点,容量为1,费用为0,然后最后一行每 ...
- 【HDOJ】【3506】Monkey Party
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
- 【HDOJ】【3516】Tree Construction
DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...
- 【HDOJ】【3480】Division
DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...
- 【HDOJ】【2829】Lawrence
DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...
- 【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...
随机推荐
- iOS开发——极光推送
1.到极光官网 https://www.jpush.cn/ 下载极光推送SDK. 具体如何集成最好参考官网的文档,以及一些失败的原因.文档非常详细,我也是参考集成的. 2.到极光推送官网注册自己的应用 ...
- 基于微软EnterpriseLib的框架(一)
1.框架模型无ORM,重点在数据库建模设计与UI框架设计上 2.多数据库支持(Enterprise Lib 默认仅支持SqlServer和Oracle,需自己扩展才能支持其他数据库,本文已扩展SQLi ...
- SQL日期操作及只获取日期的方法
datepart()函数的使用 * datepart()函数可以方便的取到时期中的各个部分*如日期:2006-07--02 18:15:36.513* ...
- 一种c#深拷贝方式完胜java深拷贝(实现上的对比)
楼主是一名asp.net攻城狮,最近经常跑java组客串帮忙开发,所以最近对java的一些基础知识特别上心.却遇到需要将一个对象深拷贝出来做其他事情,而原对象保持原有状态的情况.(实在是不想自己new ...
- Windows 7 Shortcuts (完整兼具分类有序,想我所想,赞!)
Original Link: http://www.shortcutworld.com/en/win/Windows_7.html Table of Contents: Managing 'Windo ...
- STL容器与配接器
STL容器包括顺序容器.关联容器.无序关联容器 STL配接器包括容器配接器.函数配接器 顺序容器: vector 行为类似于数组,但可以根据要求 ...
- Headfirst设计模式的C++实现——迭代器(Iterator)
iterator.h #ifndef _ITERATOR_H_ #define _ITERATOR_H_ #include "menu_item.h" class Iterator ...
- PHPstrom 增加emmet插件
之前记得使用Eclipse的时候有一个插件叫 emmet 可以实现快速开发前端,简直就是前端开发秒杀神器: 输入对应的代码一个table键就搞定了一堆代码: 在emmet的官网上 看到其实是支持的PH ...
- OpenCV2学习笔记03:Qt中配置OpenCV环境
在Qt中开发基于OpenCV的应用时,需要配置对应函数库到环境变量,这时候我们需要使用到qmake能够识别的变量来指定环境变量. INCLUDEPATH: 用于指定搜索头文件到文件夹路径. LIBS: ...
- Linux FTP服务安装和远程登录失败
问题:本机VPlayer安装pure-ftpd ftp服务,通过flashfxp从windows连接出现以下错误: [左] 正在连接到 vmare -> IP=192.168.174.133 ...