【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 ...
随机推荐
- 第十八篇、keychain保存UUID(保持唯一性,应用卸载,下载安装也不变)和获取IP地址
.h #import <Foundation/Foundation.h> #import <Security/Security.h> /**使用**/ //-(void) se ...
- iOS App Transport Security
网络请求提示:Application Transport Security has blocked a cleartext HTTP (http://) resource load since it ...
- asp:保留两位小数:
<%=Formatnumber(-6665.8999,3,-1,-1,0)%>(6665.900)一个例子用到了函数Formatnumber()的所有参数:第一个参数(-6665.8999 ...
- 从客户端中检测到有潜在危险的 Request.Form 值] 处理办法
当asp.net提交<>这些字符到aspx页面时,如果未设置 validaterequest="false",就会出现错误:从客户端(<?xml version= ...
- [leetcode] 398. Random Pick Index
我是链接 看到这道题,想到做的几道什么洗牌的题,感觉自己不是很熟,但也就是rand()函数的调用,刚开始用map<int, vector<int >>来做,tle,后来就想着直 ...
- 暑假集训(3)第四弹 -----Frogger(Poj2253)
题意梗概:青蛙王子最近喜欢上了另一只经常坐在荷叶上的青蛙公主.不过这件事不小心走漏了风声,被某fff团团员知 道了,在青蛙王子准备倾述心意的那一天,fff团团员向湖泊中注入大量的充满诅咒力量的溶液.这 ...
- Batch: Display & Redirect Output
Batch How To ... Display & Redirect Output http://www.robvanderwoude.com/battech_redirection.php ...
- Convert CString to TCHAR
Quote from: http://vctipsplusplus.wordpress.com/2008/05/21/cstring-to-tchar/ CString is a very usefu ...
- Poj 2159 / OpenJudge 2159 Ancient Cipher
1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...
- 栈(顺序存储)C++模板实现
#include <iostream> using namespace std; template <typename T> class stack{ private: int ...