sgu 130Circle dp
130. Circle
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
On a circle border there are 2k different points A1, A2, ..., A2k, located contiguously. These points connect k chords so that each of points A1, A2, ..., A2k is the end point of one chord. Chords divide the circle into parts. You have to find N - the number of different ways to connect the points so that the circle is broken into minimal possible amount of parts P.
Input
The first line contains the integer k (1 <= k <= 30).
Output
The first line should contain two numbers N and P delimited by space.
Sample Input
2
Sample Output
2 3
思路:选取一个固定点,比如P0点,然后分别和列举其他点Pj的连线,左边被分出j-1个点,右边则是i-j个点,左右分别是子图
感想:考虑不周,以为只能和最左或者最下的连接,但是只要两边不互交就行了
#include <cstdio>
using namespace std;
long long f[31];
void calc(){
f[0]=1;
f[1]=1;
f[2]=2;
for(int i=3;i<31;i++){
for(int j=1;j<=i;j++){
f[i]+=f[j-1]*f[i-j];
}
}
}
int main(){
int n;
calc();
scanf("%d",&n);
printf("%I64d %d\n",f[n],n+1);
}
sgu 130Circle dp的更多相关文章
- Little shop of flowers - SGU 104 (DP)
题目大意:把 M 朵花插入 N 个花瓶中,每个花插入不同的花瓶都有一个价值A[Mi][Nj],要使所有的花都插入花瓶,求出来最大的总价值(花瓶为空时价值是0). 分析:dp[i][j]表示前i朵花插入 ...
- SGU 422 Fast Typing(概率DP)
题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...
- 树形DP求树的重心 --SGU 134
令一个点的属性值为:去除这个点以及与这个点相连的所有边后得到的连通分量的节点数的最大值. 则树的重心定义为:一个点,这个点的属性值在所有点中是最小的. SGU 134 即要找出所有的重心,并且找出重心 ...
- 状压DP SGU 223 Little Kings
题目传送门 /* 题意:n*n的矩阵,放置k个king,要求king互相不能攻击,即一个king的8个方向都没有另外的king,求方案个数 状态压缩DP:dp[i][num[j]][s] 代表在第i行 ...
- 【SGU 390】Tickets (数位DP)
Tickets Description Conductor is quite a boring profession, as all you have to do is just to sell ...
- SGU 201 Non Absorbing DFA (DP)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意:给出一个自动机,给出所有的转移,其中还有一个 ...
- SGU 202 The Towers of Hanoi Revisited (DP+递归)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意 :n个圆盘,m个柱子的汉诺塔输出步骤. ht ...
- SGU 104. Little shop of flowers (DP)
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...
- SGU 495 Kids and Prizes:期望dp / 概率dp / 推公式
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题意: 有n个礼物盒,m个人. 最开始每个礼物盒中都有一个礼物. m个人依次随 ...
随机推荐
- C++ 一串数字三位一节,用逗号隔开表示
#include <iostream> #include <string> #include <sstream> using namespace std; stri ...
- BZOJ 2594 水管局长数据加强版(动态树)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2594 题意:给出一个无向图,边有权值.定义一条路径的长度为该路径所有边的最大值.两种操作 ...
- ubuntu下转换flv格式为mp4格式
一.环境 ubuntu 16.04 二.安装工具 sudo apt install libav-tools 三.开始转换 avconv -i input.flv -codec copy output. ...
- LightOJ 1229 Treblecross(SG函数打表 + 遍历)题解
题意:给你一串含“.”和“X”的字串,每次一个玩家可以把‘."变成“X”,谁先弄到三个XXX就赢.假如先手必赢,输出所有能必赢的第一步,否则输出0. 思路:显然如果一个X周围两格有X那么肯定 ...
- excel依赖的dll
依赖的先后顺序 stdole.dll office.dll Microsoft.Vbe.Interop.dll Microsoft.Office.Interop.Excel.dll Interop是i ...
- 【问题解决】An internal error occurred during: "Computing additional info". Could not initialize class javax.crypto.JceSecurityManager
在使用eclipse时对象后使用点操作符时总是会弹出错误,很是烦人 An internal error occurred during: "Computing additional info ...
- 【转载】Multiboot规范
转自:Multiboot规范 Multiboot规范 本文定义了Multiboot规范--提议中的引导过程标准.本文是此规范的0.6.93版. Multiboot规范简介 本章描述了一些关于Multi ...
- python 打包成tar包
def make_targz(output_filename, source_dir): with tarfile.open(output_filename, "w:gz") as ...
- Docker监控怎么做?
http://dockone.io/article/1643 监控的价值与体系在运维体系中, 监控是非常重要的组成部分.通过监控可以实时掌握系统运行的状态,对故障的提前预警,历史状态的回放等,还可以通 ...
- 基于Socket的Android手机视频实时传输
首先,简单介绍一下原理.主要是在手机客户端 (Android)通过实现Camera.PreviewCallback接口,在其onPreviewFrame重载函数里面获取摄像头当前图像数据, 然后通过S ...