Rosalind第69题:Counting Unrooted Binary Trees

Problem

Two unrooted binary trees  and  having the same  labeled leaves are considered to be equivalent if there is some assignment of labels to the internal nodes of  and  so that the adjacency lists of the two trees coincide. As a result, note that  and  must have the same splits; conversely, if the two trees do not have the same splits, then they are considered distinct.

Let  denote the total number of distinct unrooted binary trees having  labeled leaves.

Given: A positive integer  ().

Return: The value of  modulo 1,000,000.

两个无根二叉树  和  具有相同  如果对标签的内部节点分配了一些标签,则标记为标签的叶子被认为是等效的 和 这样两棵树的邻接列表重合。结果,请注意 和 必须有相同的分割;相反,如果两棵树没有相同的分割,则将它们视为不同的

让  表示具有的不同无根二叉树的总数  标记的叶子。

给定:正整数 ()。

返回值: 模1,000,000

Sample Dataset

5

Sample Output

15
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值