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: ...
随机推荐
- JavaWeb基础—上传与下载
1.上传(不能使用BaseServlet): 上传的作用,略 上传的要求(对表单和Servlet都有要求): 1.必须使用表单,而不能是超链接,method="post" 文件明显 ...
- 多线程Java Socket编程示例
package org.merit.test.socket; import java.io.BufferedReader; import java.io.IOException; import jav ...
- PostgreSQL的psql客户端各种连接错误总结
磨砺技术珠矶,践行数据之道,追求卓越价值回到上一级页面:PostgreSQL基础知识与基本操作索引页 回到顶级页面:PostgreSQL索引页[作者 高健@博客园 luckyjackgao@g ...
- 09 ORM 多表操作,创建表,添加记录
1.数据库表关系 1.一对多 为什么需要,重复字段太多 一对多关系表 Book id title price publish_id 1 python 100 1 2 php 200 2 3 go 10 ...
- LOJ #2473. 「九省联考 2018」秘密袭击
#2473. 「九省联考 2018」秘密袭击 链接 分析: 首先枚举一个权值W,计算这个多少个连通块中,第k大的数是这个权值. $f[i][j]$表示到第i个节点,有j个大于W数的连通块的个数.然后背 ...
- .net core中使用缓存(cache)
官方文档:https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-2.2#use ...
- 2_C语言中的数据类型 (十)while、for
1 循环语句 1.1 while while(条件),如果条件为真,循环继续,条件为假,循环结束 while (1)..是死循环的写法 1.2 continu ...
- Spring 单元测试 RequestContextHolder.getRequestAttributes()).getRequest(); 为空的原因
原因是因为单元测试时没有加载 web.xml 中的: <!-- spring在service层获取session和request需要创建的监听器 --> <listener> ...
- bootstrap框架中data-toggle="tab"属性会取消a标签默认行为
这几天做公司项目用了bootstrap框架,在用导航组件的过程中,我发现在a标签里面添加data-toggle="tab"属性之后,这个a标签会失去默认行为,点击a标签的时候不会跳 ...
- Web开发框架趋势
Node.js增长很快,已经冒尖了 ASP.NET MVC 发展平稳(平稳很重要) Spring MVC沾着Spring的光,渐渐超越了Struts 2 Struts作为一个整体(Struts 1 和 ...
