#abc222h. H - Beautiful Binary Tree

H - Beautiful Binary Tree

Score : 600600 points

问题描述

对于一个正整数 NN,满足以下条件的有根二叉树被称为 度为 NN 的美丽二叉树

  • 每个顶点上写有数字 0011
  • 所有叶子节点上都写有数字 11
  • 最多可以执行以下操作 N1N-1 次,使得根节点上写有数字 NN,而其他所有顶点上写有数字 00
    • 选择顶点 uuvv,其中 vv 必须是 uu 的子节点或者是“uu 的子节点的子节点”。令 auau+av,av0a_u \gets a_u + a_v, a_v \gets 0,其中 aua_uava_v 分别表示顶点 uuvv 上所写的数字。

给定 NN,求出模 998244353998244353 后,度为 NN 的美丽二叉树的数量。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

For a positive integer NN, a rooted binary tree that satisfies the following conditions is said to be a beautiful binary tree of degree NN.

  • Each vertex has 00 or 11 written on it.
  • Each vertex that is a leaf has 11 written on it.
  • It is possible to do the following operation at most N1N-1 times so that the root has NN written on it and the other vertices have 00 written on them.
    • Choose vertices uu and vv, where vv must be a child of uu or a child of "a child of uu." Let auau+av,av0a_u \gets a_u + a_v, a_v \gets 0, where aua_u and ava_v are the numbers written on uu and vv, respectively.

Given NN, find the number, modulo 998244353998244353, of beautiful binary trees of degree NN.

Constraints

  • 1N1071 \leq N \leq 10^7
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

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 11 written on it.

Sample Input 2

2

Sample Output 2

6

The binary trees that satisfy the condition are the six trees shown below.

image

Sample Input 3

222

Sample Output 3

987355927

Sample Input 4

222222

Sample Output 4

675337738

update @ 2024/3/10 09:48:30