首页 > 其他分享 >[CF9D]How many trees?

[CF9D]How many trees?

时间:2023-06-01 10:26:12浏览次数:38  
标签:le 题目 trees How 枚举 二叉树 CF9D

2023-06-01

题目

题目传送门

难度&重要性(1~10):5

题目来源

Codeforces,luogu

题目算法

dp

解题思路

深度最大为 \(n\left(1\le n\le 35\right)\) 的二叉树暴力枚举显然不行,考虑dp。
设 \(f_{i,j}\) 表示有 \(i\) 个节点时,深度不大于 \(j\) 的二叉树数量。
答案容斥:\(f_{n,n}-f_{n,h-1}\)。
这里,我们可以枚举 \(i-1\) 的左右儿子数量的状况来转移:

\[f_{i,j}=\sum\limits_{k=0}^if_{k,j-1}\cdot f_{i-k-1,j-1} \]

注意,这里我们要先枚举 \(j\),再枚举 \(i\),以保证前面的状态都已经枚举过。

完成状态

已完成

标签:le,题目,trees,How,枚举,二叉树,CF9D
From: https://www.cnblogs.com/OIerBoy/p/17448176.html

相关文章

  • 【Oracle】Show the change history of tbs' size
     注意:脚本都从dba_hist_tbspc_space_usage系统视图获取数据,但是这个系统视图中保存的数据的时间是依赖AWR采样数据保留期限的。所以你从这个系统视图可能查找不出很早之前的表空间数据使用情况,如果需要历史的表空间使用数据,可能需要定期采集数据并存储到起来。 Innonmult......
  • 查看nebula版本号 console里show hosts graph
    (root@nebula)[(none)]>showhostsgraph+-------------+------+----------+---------+--------------+---------+|Host|Port|Status|Role|GitInfoSha|Version|+-------------+------+----------+---------+--------------+---------+|&q......
  • How to use the shell command to get the version of Linux Distributions All In On
    HowtousetheshellcommandtogettheversionofLinuxDistributionsAllInOne如何使用shell命令获取Linux发行版的版本hostnamectlcat/etc/os-releaselsb_release-aLinuxDistributionsDebianUbuntuRaspberryPiOShttps://en.wikipedia.org/wiki/L......
  • leetcode 617. Merge Two Binary Trees
    Giventwobinarytreesandimaginethatwhenyouputoneofthemtocovertheother,somenodesofthetwotreesareoverlappedwhiletheothersarenot.Youneedtomergethemintoanewbinarytree.Themergeruleisthatiftwonodesoverlap,thensumn......
  • How can get custom claim
    @@abp7.0openiddictsettingtokenValidateLifetime-->https://stackoverflow.com/questions/75408673/how-can-i-change-the-openiddict-accesstoken-lifetime-in-apb-7 ##--->thanks,ifoundeditPreConfigure<OpenIddictServerBuilder>(builder=>{......
  • show parameter sga;
    安装Oracle时,为了均衡电脑性能和数据库性能,Oracle一个实例默认内存占用大小为物理内存的1/8。如环境不需要分配那么大的内存来支撑Oracle,可通过修改sga_max_size的值来减少系统中内存占用过大问题。步骤如下:1.cmdsqlplussystem账户登录2.showparametersga;--显示内存分......
  • ctfshow刷题笔记-misc入门
    ctfshow-misc入门图片篇(文件结构)misc241.在010Editor中打开文件,根据鼠标自动提示找到图片宽高对应的地方biWidth指定图象的宽度,单位是象素。biHeight指定图象的高度,单位是象素。2.修改图片高度为250px并另存3.打开后得到flagmisc251.从网上找到的脚本(将脚本和图片......
  • How to boot the Raspberry Pi system from a USB Mass Storage Device All In One
    HowtoboottheRaspberryPisystemfromaUSBMassStorageDeviceAllInOne如何从USB启动树莓派引导系统/如何从USB大容量存储设备启动RaspberryPi系统https://www.raspberrypi.com/news/pi-3-booting-part-i-usb-mass-storage-boot/officaildocsThispag......
  • Webpack and Babel — What are they, and how to use them with React
    摘抄自:https://medium.com/@agzuniverse/webpack-and-babel-what-are-they-and-how-to-use-them-with-react-5807afc82ca8WebpackandBabel—Toolswecan’tcodewithoutWe’llbeconfiguringbothoftheseforourReactproject,sofirsthere’saquickexplanation......
  • Paper Reading: Adaptive Neural Trees
    目录研究动机文章贡献自适应神经树模型拓扑与操作概率模型与推理优化实验结果模型性能消融实验可解释性细化阶段的影响自适应模型复杂度优点和创新点PaperReading是从个人角度进行的一些总结分享,受到个人关注点的侧重和实力所限,可能有理解不到位的地方。具体的细节还需要以原文......