#abc222h. H - Beautiful Binary Tree
H - Beautiful Binary Tree
Score : points
问题描述
对于一个正整数 ,满足以下条件的有根二叉树被称为 度为 的美丽二叉树。
- 每个顶点上写有数字 或 。
- 所有叶子节点上都写有数字 。
- 最多可以执行以下操作 次,使得根节点上写有数字 ,而其他所有顶点上写有数字 。
- 选择顶点 和 ,其中 必须是 的子节点或者是“ 的子节点的子节点”。令 ,其中 和 分别表示顶点 和 上所写的数字。
给定 ,求出模 后,度为 的美丽二叉树的数量。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
For a positive integer , a rooted binary tree that satisfies the following conditions is said to be a beautiful binary tree of degree .
- Each vertex has or written on it.
- Each vertex that is a leaf has written on it.
- It is possible to do the following operation at most times so that the root has written on it and the other vertices have written on them.
- Choose vertices and , where must be a child of or a child of "a child of ." Let , where and are the numbers written on and , respectively.
Given , find the number, modulo , of beautiful binary trees of degree .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
1
Sample Output 1
1
The only binary tree that satisfies the condition is a tree with one vertex whose root has written on it.
Sample Input 2
2
Sample Output 2
6
The binary trees that satisfy the condition are the six trees shown below.
Sample Input 3
222
Sample Output 3
987355927
Sample Input 4
222222
Sample Output 4
675337738
update @ 2024/3/10 09:48:30