题目链接:

http://poj.org/problem?id=3597

Polygon Division

Time Limit: 2000MS
Memory 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

题意

把正凸多边形剖成四边形和三角形的所有方案。

题解

[port]

代码

#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 多边形剖分的更多相关文章

  1. POJ 3597 Polygon Division (DP)

    题目链接 题意:把一个正多边形分成数个三角形或者四边形,问有多少种方案. 题解: 如果分出的全为三角形的话,那就是正多边形三角剖分问题.它的结果就是Catalan数.现在也可以划分出四边形的话,可以采 ...

  2. poj 1654 Area(多边形面积)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17456   Accepted: 4847 Description ...

  3. poj 1265 Area 面积+多边形内点数

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5861   Accepted: 2612 Description ...

  4. 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数012,polygon,多边形

    <zw版·Halcon-delphi系列原创教程> Halcon分类函数012,polygon,多边形 为方便阅读,在不影响说明的前提下,笔者对函数进行了简化: :: 用符号“**”,替换 ...

  5. poj 1179 Polygon

    http://poj.org/problem?id=1179 Polygon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions:  ...

  6. poj 1654 Area(求多边形面积 && 处理误差)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16894   Accepted: 4698 Description ...

  7. [svg 翻译教程]Polyline(折线)polygon(多边形)

    原文: http://tutorials.jenkov.com/svg/polygon-element.html Polyline 虽然说这个 元素我没用过,但是还是蛮强大的,也翻译下 示例 < ...

  8. [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 ...

  9. poj 1654 Area (多边形求面积)

    链接:http://poj.org/problem?id=1654 Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions:  ...

随机推荐

  1. JS控制上传文件个数

    <html><body>    <h3>js控制文件上传数量</h3>    <form action="" enctype= ...

  2. Source Insight 创建工程(linux-2.6.22.6内核源码)

    1. 软件设置 安装完Source Insight,需要对其进行设置添加对“.S”汇编文件的支持: 2. 新建linux-2.6.22.6工程 1)选择工程存放的路径: 2)下载linux-2.6.2 ...

  3. go 交叉编译,部署

    go web 部署 交叉编译 go 语言有个强大的地方就是 交叉编译 windows --cmd 设置环境变量-mac SET CGO_ENABLED=0 SET GOOS=darwin SET GO ...

  4. Android签名验证漏洞POC及验证

    poc实际上就是一段漏洞利用代码,以下是最近炒得很火Android签名验证漏洞POC,来自https://gist.github.com/poliva/36b0795ab79ad6f14fd8 #!/ ...

  5. 【FJOI2016】建筑师

    安利另外一篇\(blog\) 密码泥萌都知道 题面 题解 为了描述方便,这里将建筑称作\(zsy\) 高度为\(n\)的\(zsy\)无论如何都能从左右两侧看到.剩下的部分,从左边看到的是前缀\(ma ...

  6. 1444: [Jsoi2009]有趣的游戏

    1444: [Jsoi2009]有趣的游戏 链接 分析: 如果一个点回到0号点,那么会使0号点的概率增加,而0号点的概率本来是1,不能增加,所以这题用期望做. 设$x_i$表示经过i的期望次数,然后初 ...

  7. Python之时间模块、random模块、json与pickle模块

    一.时间模块 1.常用时间模块 import time # 时间分为三种格式 #1.时间戳---------------------以秒计算 # start= time.time() # time.s ...

  8. [webapp]移动平台各浏览器的分辨率适配

    搞webapp适配了N多浏览器,记一下各浏览器碰到的需要注意的地方. 目前发现firefox是最难适配的. 1.firefox只有在onload之后才能取到正确的innerwidth值. 2.目前版本 ...

  9. 复杂值vs原始值&&内存空间

    写在前面 最近在读<JavaScript启示录>,这本书不是JavaScript的详尽的参考指南,但是把对象作为了解JavaScript的透镜,受益匪浅. 那么我们先来聊一下JavaScr ...

  10. 简单可行的code review规则

    前言 曾经有一段垃圾代码放在我的面前,我没有拒绝,等我真正开始接手的时候我才后悔莫及,程序员最痛苦的事莫过于此! 每当接手别人的代码,都有一种想重新写一遍的感觉,等到别人再来接手你的代码时,同样的感觉 ...