HDU 1294 Rooted Trees Problem
题目大意:求有n个节点的树有几种?
题解:http://www.cnblogs.com/keam37/p/3639294.html
#include <iostream>
typedef long long LL;
using namespace std;
LL f[41];
int cnt[41],n;
LL C(LL n,LL m){
m=m<(n-m)?m:(n-m);
LL ans=1;
for(int i=1;i<=m;i++)ans=ans*(n-i+1)/i;
return ans;
}
int dfs(int temp,int left){
if(left==0){
LL ans=1;
for(int i=1;i<=n;i++){
if(cnt[i]==0)continue;
ans=ans*C(f[i]+cnt[i]-1,cnt[i]);
}
f[n]+=ans; return 0;
}
for(int i=temp;i<=left;i++)cnt[i]++,dfs(i,left-i),cnt[i]--;
return 0;
}
int main(){
f[1]=f[2]=1;
for(n=3;n<=40;n++)dfs(1,n-1);
while(cin>>n)cout<<f[n]<<endl;
return 0;
}
HDU 1294 Rooted Trees Problem的更多相关文章
- HDU p1294 Rooted Trees Problem 解题报告
http://www.cnblogs.com/keam37/p/3639294.html keam所有 转载请注明出处 Problem Description Give you two definit ...
- HDU1294 Rooted Trees Problem(整数划分 组合数学 DP)
讲解见http://www.cnblogs.com/IMGavin/p/5621370.html, 4 可重组合 dfs枚举子树的节点个数,相乘再累加 1 #include<iostream& ...
- 【Aizu - ALDS1_7_A】Rooted Trees(树的表达)
Rooted Trees Descriptions: A graph G = (V, E) is a data structure where V is a finite set of vertice ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu 1402 A * B Problem Plus FFT
/* hdu 1402 A * B Problem Plus FFT 这是我的第二道FFT的题 第一题是完全照着别人的代码敲出来的,也不明白是什么意思 这个代码是在前一题的基础上改的 做完这个题,我才 ...
- HDU 4291 A Short problem(2012 ACM/ICPC Asia Regional Chengdu Online)
HDU 4291 A Short problem(2012 ACM/ICPC Asia Regional Chengdu Online) 题目链接http://acm.hdu.edu.cn/showp ...
- hdu 2993 MAX Average Problem(斜率DP入门题)
题目链接:hdu 2993 MAX Average Problem 题意: 给一个长度为 n 的序列,找出长度 >= k 的平均值最大的连续子序列. 题解: 这题是论文的原题,请参照2004集训 ...
- [HDU - 5170GTY's math problem 数的精度类
题目链接:HDU - 5170GTY's math problem 题目描述 Description GTY is a GodBull who will get an Au in NOI . To h ...
- cdq分治(hdu 5618 Jam's problem again[陌上花开]、CQOI 2011 动态逆序对、hdu 4742 Pinball Game、hdu 4456 Crowd、[HEOI2016/TJOI2016]序列、[NOI2007]货币兑换 )
hdu 5618 Jam's problem again #include <bits/stdc++.h> #define MAXN 100010 using namespace std; ...
随机推荐
- powerdesigner反向MySQL5.1数据库 生成ER图
我用的powerdesigner是15.1版本,数据库是MySQL5.1.57 (1)首先新建一个“PhysicalDataModel”类型的文件,然后点击“Database”->"C ...
- CocoaPods 出现 OTHER_LDFLAGS 错误的解决方法
CocoaPods 出现 OTHER_LDFLAGS 错误的解决方法 在一些项目中运行 pod install 后经常会出现如下错误 [!] The target `项目名 [Debug]` over ...
- Oracle Select into 用Sql server替换
--Oracle: DECLARE n_count int; begin Select count(*) into n_count from from M_Test where ENTITYLSH = ...
- C++链接库
静态链接库在程序编译链接过程中就导入lib文件并且包含在生成的exe文件里,而动态链接库DLL是在程序运行中由程序加载和卸载的,也就是说它是动态的,当然动态链接库DLL也可以静态加载当做静态来用: 静 ...
- MySql级联操作
转自:http://blog.csdn.net/codeforme/article/details/5539454 外键约束对子表的含义: 如果在父表中找不到候选键,则不允许在子表上进行i ...
- HBase API详解
一.Java API和HBase数据模型的关系 在Java中,与HBase数据库存储管理相关的类包括HBaseAdmin.HBaseConfiguration.HTable.HTableDescrip ...
- JQuery的Select操作集合
jQuery获取Select选择的Text和Value: 语法解释: $("#select_id").change(function(){//code...}); //为Sel ...
- 从零开始PHP学习 - 第三天
写这个系列文章主要是为了督促自己 每天定时 定量消化一些知识! 同时也为了让需要的人 学到点啥~! 本人技术实在不高!本文中可能会有错误!希望大家发现后能提醒一下我和大家! 偷偷说下 本教程最后的目 ...
- Gulp browserify livereload
Gulp browserify livereload 之前在browserify那个博文中介绍了gulp + browserify 不过那个配置还不能满足日常需要 搬运 https://github. ...
- CSS3 旋转 太阳系
参考https://www.tadywalsh.com/web/cascading-solar-system/ 首先 旋转有两种方式 一种是使用 transform-origin 另一种是tran ...