SGU 130
SGU130,用k条弦将一个圆分成k+1份的方法数。
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <string.h>
using namespace std; long long dp[]; long long f(int k) {
if (dp[k]) {
return dp[k];
}
if (k <= ) {
return ;
}
long long ans = ;
for (int i = ; i < k; i++) {
ans += f(i) * f(k - - i);
}
return dp[k] = ans;
} int main() {
int k;
scanf("%d", &k);
memset(dp, , sizeof(dp));
printf("%lld %d\n", f(k), k + );
}
SGU 130的更多相关文章
- Circle - SGU 130(递推)
题目大意:一个圆上有2K个点,用K个线把他们连接起来,求出这些线最少可以把这个圆分成P部分,有N种分割方法.输出N和P. 分析:分割线一定是相互不相交的线,所以可以把这写分成两部分,f[i] += f ...
- SGU 130.Circle
答案为Catalan数C(2k, k)/(k+1) #include <stdio.h> using namespace std; int k; int main() { scanf(&q ...
- 今日SGU 5.4
SGU 127 题意:给你n个数字,和m,k,问你有多少个数字的m次幂可以被k整除 收获:快速幂 #include<bits/stdc++.h> #define de(x) cout< ...
- ascii码所有字符对照表(包含汉字和外国文字)
http://www.0xaa55.com/thread-398-1-1.html看到了0xaa55的这个帖子,想起了2年前我在51cto发的一个帖子http://down.51cto.com/dat ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- ASP.NET常见面试题及答案(130题)
1.C#中 property 与 attribute(抽像类)的区别,他们各有什么用处,这种机制的好处在哪里?答:property和attribute汉语都称之为属性.不过property是指类向外提 ...
- SGU 495. Kids and Prizes
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...
- ACM: SGU 101 Domino- 欧拉回路-并查集
sgu 101 - Domino Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Desc ...
- 【SGU】495. Kids and Prizes
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...
随机推荐
- Gitlab 与 Git Windows 客户端一起使用的入门流程
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3824934.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...
- HDU1857题解(逆向思维trie)
题目link:http://acm.hdu.edu.cn/showproblem.php?pid=1857 先简述一下题目: 有一个RXC的字母矩形,R,C在500内,要匹配m个单词,m在100000 ...
- Centos6.5网络无法连接问题
1. 先进入对应文件夹: cd /etc/sysconfig/network-scripts/ 2.获取root权限: su 然后输入root密码 3.修改ifcfg-eth0 vi ifcf ...
- PDF编辑、删除、替换某页面或文字
在工作中,我们常常会用到PDF,当然尤其是会计,我虽然是程序员,但是“小老鼠”是会计,前几天,突然问我,怎么样将PDF中的某个页面替换掉,也就是删掉某页然后再从另外一个地方找一页补上来: 还需要改变这 ...
- NSS_03 过滤器
asp.net mvc3有四类过滤器:授权, 操作,结果, 异常.操行的顺序为:授权,操作,结果,异常. 首先看一下TempData: 数据只能经过至多一次的Controller传递, 并且每个元素至 ...
- <script type="text/html"></script> js模版使用
<div></div> <script type="text/html" id="javascript_template"> ...
- const和#define的区别
在刷题的时候经常遇到定义全局常量我一般都是用#define(可能是因为很少接触const的原因) 在昨天做到51nod1082时照常暴力用#define定义最大.可是提交超时..... 后来看他人写的 ...
- 从零学起PHP
数据库连接conn.php <?php //第一步:链接数据库 $conn=@mysql_connect("localhost:3306","root", ...
- liger 的 ligerDialog 的使用。
/// 查看页面,跳出一个新的添加窗口 function AddMessage() { $.ligerDialog.open({ url: UrlAddMessage, height: , width ...
- VB.Net 字符串加密类
Public Class Cls_JM '使用 'Dim Jm As New Cls_JM(2) 'Dim strTmp As String 'Jm.jiemi(strTmp) 'Jm.Jiami(s ...