POJ 3597 Polygon Division 多边形剖分
题目链接:
http://poj.org/problem?id=3597
Polygon Division
Time Limit: 2000MSMemory Limit: 131072K
#### 问题描述
> Given a regular polygon, there are numerous ways to divide it into several triangles and/or quadrangles by adding some diagonals that do not properly intersect each other. For example, Figure 4 shows all ten different divisions of a regular pentagon into triangles and quadrangles.
>
> Figure 4: Divisions of a regular pentagon into triangles and quadrangles
>
> Given n, the number of sides of the polygon, compute the number of such divisions.
#### 输入
> The input contains multiple test cases. Each test case consists of a single integer n (3 ≤ n ≤ 5000) on a separate line. The input ends where EOF is met.
#### 输出
> For each test case, print the answer modulo 264 on a separate line.
####样例输入
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
样例输出
1
3
10
38
154
654
2871
12925
题意
把正凸多边形剖成四边形和三角形的所有方案。
题解
代码
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<ctime>
#include<vector>
#include<cstdio>
#include<string>
#include<bitset>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
#define X first
#define Y second
#define mkp make_pair
#define lson (o<<1)
#define rson ((o<<1)|1)
#define mid (l+(r-l)/2)
#define sz() size()
#define pb(v) push_back(v)
#define all(o) (o).begin(),(o).end()
#define clr(a,v) memset(a,v,sizeof(a))
#define bug(a) cout<<#a<<" = "<<a<<endl
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define scf scanf
#define prf printf
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef vector<pair<int,int> > VPII;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFL=0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-8;
const double PI = acos(-1.0);
//start----------------------------------------------------------------------
const int maxn=5555;
ULL f[maxn],g[maxn];
void pre(){
clr(g,0),clr(f,0);
g[1]=g[2]=f[1]=f[2]=1;
for(int i=3;i<maxn;i++){
g[i]=0;
for(int j=2;j<i;j++) g[i]+=f[j]*f[i-j+1];
f[i]=g[i];
for(int j=2;j<=i-2;j++) f[i]+=f[j]*g[i-j+1];
}
}
int main() {
pre();
int tc,kase=0;
int n;
while(scf("%d",&n)==1){
if(n<3) puts("0");
prf("%llu\n",f[n]);
}
return 0;
}
//end-----------------------------------------------------------------------
POJ 3597 Polygon Division 多边形剖分的更多相关文章
- POJ 3597 Polygon Division (DP)
题目链接 题意:把一个正多边形分成数个三角形或者四边形,问有多少种方案. 题解: 如果分出的全为三角形的话,那就是正多边形三角剖分问题.它的结果就是Catalan数.现在也可以划分出四边形的话,可以采 ...
- poj 1654 Area(多边形面积)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17456 Accepted: 4847 Description ...
- poj 1265 Area 面积+多边形内点数
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5861 Accepted: 2612 Description ...
- 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数012,polygon,多边形
<zw版·Halcon-delphi系列原创教程> Halcon分类函数012,polygon,多边形 为方便阅读,在不影响说明的前提下,笔者对函数进行了简化: :: 用符号“**”,替换 ...
- poj 1179 Polygon
http://poj.org/problem?id=1179 Polygon Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
- poj 1654 Area(求多边形面积 && 处理误差)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16894 Accepted: 4698 Description ...
- [svg 翻译教程]Polyline(折线)polygon(多边形)
原文: http://tutorials.jenkov.com/svg/polygon-element.html Polyline 虽然说这个 元素我没用过,但是还是蛮强大的,也翻译下 示例 < ...
- [javascript svg fill stroke stroke-width points polygon属性讲解] svg fill stroke stroke-width points polygon绘制多边形属性并且演示polyline和polygon区别讲解
<!DOCTYPE html> <html lang='zh-cn'> <head> <title>Insert you title</title ...
- poj 1654 Area (多边形求面积)
链接:http://poj.org/problem?id=1654 Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
随机推荐
- 用windows或ubuntu访问apfs或mac分区
MacBook读写不了NTFS,Windows也读写不了APFS和Mac OS 扩展分区,Ubuntu又用的是ext4分区,有时候想用U盘传点东西真的费劲.著名公司Paragon Software开发 ...
- mysql——leetcode问题记录
问题: 表1: Person +-------------+---------+ | 列名 | 类型 | +-------------+---------+ | PersonId | int | | ...
- 【树形DP】洛谷P1352_没有上司的舞会
本人第一篇Blog,初学树形DP,心情别样鸡冻... 好了废话不多说,我们来看看题目[传送门] 某大学有N个职员,编号为1~N.他们之间有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是 ...
- 复制web项目时注意修改web项目名
改web项目的项目名可以右击->properties->搜索web找到settings->修改context name
- # 20155229 2016-2017-2 《Java程序设计》第七周学习总结
20155229 2016-2017-2 <Java程序设计>第七周学习总结 教材学习内容总结 第十二章 lambda的主体是一个表达式,而不是一个代码块.仅仅能在lambda表达式中封装 ...
- WPF 播放Flash
原文:WPF 播放Flash WPF中没有直接提供播放Flash的控件. 可以使用WebBrowser来打开,代码如下: <Window x:Class="Nankang.Itacat ...
- 二维码QR Code简介及其解码实现(zxing-cpp)
二维码QR Code(Quick Response Code)是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大.可靠性高.可表示汉字及图象多种 ...
- P3592 [POI2015]MYJ
P3592 [POI2015]MYJ 一道比较烦的区间dp.. 昨天上课讲到了这题,然后就在lg翻到了 然后调了很久很久..... 设\(f[l][r][k]\)为区间\([l,r]\)中,最小值\( ...
- 【windows】窗口锁定状态如何关机
在锁定界面下方有一个——切换用户,点击,过一会右下角就有一个红色的圆圈,就可以关机了.
- list add() 和 addall()的区别
http://blog.tianya.cn/post-4777591 如果有多个已经被实例化的List 集合,想要把他们组合成一个整体,并且,这里必须直接使用List 自身提供的一个方法List.ad ...