题目链接:

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. Linux下onvif客户端获取ipc摄像头 GetServices:获取媒体地址(有的h265摄像头必须要这个接口)

    GetServices:获取媒体地址(有些h265的摄像头必须用到这个接口,得到获取能力时没获取到的另一个媒体地址) 鉴权:但是在使用这个接口之前是需要鉴权的.ONVIF协议规定,部分接口需要鉴权,部 ...

  2. hive--数据仓库

    1.1.1     hive是什么? Hive是基于 Hadoop 的一个数据仓库工具: 1.       hive本身不提供数据存储功能,使用HDFS做数据存储: 2.       hive也不分布 ...

  3. TIDB数据集群部署

    TIDB 数据库集群 一.TiDB数据介绍 1.1.TiDB数据简介 TiDB 是 PingCAP 公司设计的开源分布式 HTAP (Hybrid Transactional and Analytic ...

  4. SpringIDE的安装

    要安装SpringIDE,需要先知道当前eclipse的版本,打开Eclipse,Help -> About Eclipse 然后去 http://spring.io/tools/sts/all ...

  5. 【转】numpy教程

    [转载说明] 本来没有必要转载的,只是网上的版本排版不是太好,看的不舒服.所以转过来,重新排版,便于自己查看. 基础篇 NumPy的主要对象是同种元素的多维数组. 这是一个所有的元素都是一种类型.通过 ...

  6. Velocity的学习1

    Velocity 是一个基于Java的的模板引擎,通过特定的语法,速度可以获取在的Java语言中定义的对象,从而实现界面和Java的代码的真正分离,这意味着可以使用Velocity替代JSP的开发模式 ...

  7. selenium select 选择下拉框

    实战百度首页设置,浏览偏好设置. 打开首页,在非登录的情况下,查看分析页面元素,我们可以看到,我们首先要点击的是设置, 接着点击,搜索设置, 然后select选择下拉框. select_by_inde ...

  8. TPO-20-Apply for the undergraduate research fund

    /*    加粗:语音部分 *    红色:单词部分 *    斜体:语法部分 *    下划线:信号词/句 */ 第 1 段 1.Listen to a conversation between a ...

  9. Unity 几何着色器

    Unity 几何着色器 shaderGeometry Shader几何着色器 Unity 几何着色器 如果学习不能带来价值,那将毫无意义 简介     在顶点和片段着色器之间有一个可选的着色器,叫做几 ...

  10. Mysql Mariadb 密码问题

    mysql密码遗忘和登陆报错问题   mysql登录密码忘记,其实解决办法很简单,只需要在mysql的主配置文件my.cnf里添加一行“跳过授权表”的参数选择即可! 在my.cnf中添加下面一行:[r ...