【CF724F】Uniformly Branched Trees】的更多相关文章

[CF724F]Uniformly Branched Trees 题意:询问n个点的每个非叶子点度数恰好等于d的不同构的无根树的数目. $n\le 1000,d\le 10$. 题解:先考虑有根树的版本.我们用$DP(n,m,k)$表示n个点,其中根的度数为m,其余点度数为d,根的最大的儿子的子树不能超过k的方案数.转移时我们可以枚举有多少个子树大小为k的.假如有i个,则贡献为:$DP(n-ik,m-i,k-1)\times{{DP(k,d-1,k-1)+i-1} \choose{i}}$,采用…
题意:询问n个点的每个非叶子点度数恰好等于d的不同构的无根树的数目. n≤1000,d≤10n≤1000,d≤10. 题解: 这题真的是一道非常好的题 首先考虑有根树 定义f[i][j][k]表示i个点,根节点度数为j,最大子树大小为k 转移的时候枚举最大子树以及个数,这样保证了不重构 通过记录了根节点的度数我们就能很好的转移了 DP(n−ik,m−i,k−1)×C(DP(k,d−1,k−1)+i−1,i) f[i+1][I][1]=1 f[1][0][0]=1 初值怎么赋呢 考虑无根的时候 由…
CF724F Uniformly Branched Trees 有根树可以统计.无根树难以统计.因为可以换根. 所以不让换根:只要两个无根树在重心位置不同构,就一定不同构 每个本质不同的树在重心位置统计上. f[i][j][k]i个点根节点度数j,最大子树不超过k.枚举k大小的子树个数转移. 重心两个? 特殊考虑.两端f[n/2][d-1][n/2-1]=x,x*(x-1)/2+x 边界考虑到. #include<bits/stdc++.h> #define reg register int…
[HDU1693]Eat the Trees(插头dp) 题面 HDU Vjudge 大概就是网格图上有些点不能走,现在要找到若干条不相交的哈密顿回路使得所有格子都恰好被走过一遍. 题解 这题的弱化版本吧... 因为可以任意分配哈密顿回路的数量,因此根本不需要再考虑插头的配对问题了,那么直接分情况转移就好啦. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #in…
F - Uniformly Branched Trees #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long long using namespace std; ;…
[科普]什么是BestCoder?如何参加? Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8113    Accepted Submission(s): 3095 Problem Description There are a lot of trees in an area. A peasant…
[题意] 给定一棵树每个结点的权重和路径(路径用LR串表示),输出这棵树的层次遍历 [思路] 注意输入输出,sscanf用来格式化地截取需要的数据,strchr来在字符串中查找字符的位置 [Accepted] #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<queue> using n…
插头DP 插头dp模板题…… 这题比CDQ论文上的例题还要简单……因为不用区分左右插头(这题可以多回路,并不是一条哈密尔顿路) 硬枚举当前位置的状态就好了>_< 题解:http://blog.csdn.net/xymscau/article/details/6756351 //HDU 1693 #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #incl…
problem 872. Leaf-Similar Trees 参考 1. Leetcode_easy_872. Leaf-Similar Trees; 完…
题目如下: Given an array of unique integers, each integer is strictly greater than 1. We make a binary tree using these integers and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values…