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: ...
随机推荐
- C语言实现随机数
最近在看<The C Programming Language>这本书,看到一个关于随机数的知识点,有种豁然开朗的感觉.以前总靠死记硬背,也不明白为啥是这样,而且总把srand()遗漏.相 ...
- 2017-2018-1 20155330 《信息安全系统设计基础》加分项目--实现mypwd
2017-2018-1 20155330 <信息安全系统设计基础>加分项目--实现mypwd pwd命令 命令功能:查看"当前工作目录"的完整路径. 通过man命令查看 ...
- PyQt5 笔记(01):嵌套布局
PyQt5 有四种布局:水平(QHBoxLayout).竖直(QVBoxLayout).网格(QGridLayout).表单(QFormLayout)在窗体中单一的布局应该不难,但若是比较复杂的布局, ...
- Velocity学习4
Velocity是一个基于java的模板引擎(template engine).它允许任何人仅仅简单的使用模板语言(template language)来引用由java代码定义的对象. 当Veloci ...
- 「PKUSC2018」最大前缀和
题面 题解 可以想到枚举成为最大前缀和的一部分的数 设\(sum_i=\sum\limits_{j\in i}a[j]\) 设\(f_i\)表示满足\(i\)的最大前缀和等于\(sum_i\)的方案数 ...
- 【BZOJ1044】[HAOI2008]木棍分割
[BZOJ1044][HAOI2008]木棍分割 题面 bzoj 洛谷 题解 第一问显然可以二分出来的. 第二问: 设\(dp[i][j]\)表示前\(i\)个,切了\(j\)组的方案数 发现每次转移 ...
- .net core中automapper的使用
automapper 是将两个类中的相同字段进行映射,也可以指定字段进行映射:将 UserDao的id 映射为 User 的age CreateMap<UserDao, User>() . ...
- 【windows server 2008R2】windows server 2008R2自动重启
客户反映2018.3.20早上8点多数据库重启. 我找了半天原因,看了一下告警日志没发现什么问题.后来我再跟他确认,他说他练上去的时候正在准备桌面.这感觉像是服务器重启导致数据库重启. 于是我远程上去 ...
- node.js学习笔记(三)——事件循环
要理解事件循环,首先要理解事件驱动编程(Event Driven Programming).它出现在1960年.如今,事件驱动编程在UI编程中大量使用.JavaScript的一个主要用途是与DOM交互 ...
- Oracle10g 客户端安装与配置说明
1:百度文库 http://wenku.baidu.com/link?url=bA-FrFMaqxkoifwz-oiPeU5QmMVVJyy8rYDBryhTUCJywpkDS0VNJcObCIM8l ...
