[几何 区间DP] Codeforces 438C & 437E. The Child and Polygon
来源:互联网 发布:数据字典中的数据项 编辑:程序博客网 时间:2024/06/08 16:39
题目是求三角剖分个数
令
我们找到一个点
那么让
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;const int N=210,P=1e9+7;typedef long long ll;int n;int f[N][N]; struct Pt{ ll x,y; ll val(){ return x*x+y*y; } friend Pt operator -(const Pt &a,const Pt &b){ return {a.x-b.x,a.y-b.y}; } friend bool operator ==(const Pt &a,const Pt &b){ return a.x==b.x && a.y==b.y; } friend bool operator !=(const Pt &a,const Pt &b){ return !(a==b); }}a[N];inline int sgn(ll x){ if(x==0) return 0; return x>0?1:-1;}inline ll cross(const Pt &a,const Pt &b){ return a.x*b.y-a.y*b.x;}int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i].x,&a[i].y); ll area=0; for(int i=1;i<=n;i++) area+=cross(a[i],a[i%n+1]); if(area<0) reverse(a+1,a+1+n); for(int i=1;i<n;i++) f[i][i+1]=1; for(int k=3;k<=n;k++) for(int i=1;i+k-1<=n;i++){ for(int j=i+1;j<i+k-1;j++) if(cross(a[j]-a[i],a[i+k-1]-a[i])>0) (f[i][i+k-1]+=1LL*f[i][j]*f[j][i+k-1]%P)%=P; } cout<<f[1][n]<<endl; return 0;}
阅读全文
0 0
- [几何 区间DP] Codeforces 438C & 437E. The Child and Polygon
- Codeforces 437E The Child and Polygon(区间DP)
- Codeforces 437E The Child and Polygon(区间DP) 2017/1/10
- CodeForces 438 C.The Child and Polygon(dp+计算几何)
- codeforces 437C The Child and Toy
- CodeForces 437C The Child and Toy
- Codeforces 437C The Child and Toy
- codeforces-437C-The Child and Toy
- CodeForces 437C The Child and Toy
- Codeforces-437C-The Child and Toy
- CodeForces 437C The Child and Toy
- Codeforces 438E The Child and Binary Tree
- codeforces 438D The Child and Sequence(线段树:单点更新+区间取模+区间和)
- Codeforces 437C The Child and Toy(贪心)
- codeforces 437C The Child and Toy 贪心
- Codeforces 437C The Child and Toy(贪心)
- H - The Child and Toy-CodeForces 437C-水题
- Codeforces 437C The Child and Toy( 贪心)
- Aapt2异常
- (Android UI)colorAccent,colorPrimary,colorPrimaryDark
- linux中批量添加用户
- 《传智播客全方位打造“1024程序员节”,致敬百万程序员》
- 深刻理解android的Fragment生命周期,到底在干嘛。
- [几何 区间DP] Codeforces 438C & 437E. The Child and Polygon
- 不常用LSA
- 简易的渐变沉浸式
- 第八周(2)项目4—广义表算法库及应用
- SQL Server触发器
- 贴一份软件包自带的SNMP配置说明
- 二叉树的前序遍历(递归和非递归)
- const 、& 、*在变量定义时的含义
- [Git报道.1]GIT windows的安装(msysGit)