#P7857. 「EZEC-9」Meltel
「EZEC-9」Meltel
Background
Only you are unforgivable.
"Only you cannot be forgiven."
Only you forgave everything about me.
"Only you forgave all of me."
Only you took everything from me, devoured it all,
"Only you destroyed my world,"
burned it all to ashes and turned everything into nothing.
"Burned it to the ground, mountains collapsing and the earth splitting."
Problem Description
Given a positive integer , for , count the number of labeled forests consisting of labeled rooted trees on nodes such that there exist exactly binary trees.
Take the result modulo .
A binary tree is defined as a labeled rooted tree where each node has at most children.
Two forests are considered different if and only if there exists a node whose parent is different (treat the root as having no parent).
Input Format
The first line contains one positive integer .
Output Format
Output one line with non-negative integers, representing the answers for .
3
0 9 6 1
4
4 60 48 12 1
5
85 560 480 150 20 1
Hint
[Explanation for Sample 1]
With nodes, only binary trees can appear, so the number of valid configurations for is .
There are labeled rooted binary trees on nodes, so the number of valid configurations for is .
There are labeled rooted binary trees on nodes, so the number of valid configurations for is .
A single node is also considered a labeled rooted binary tree, so the number of valid configurations for is .
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (5 points): .
- Subtask 2 (5 points): .
- Subtask 3 (30 points): .
- Subtask 4 (30 points): .
- Subtask 5 (30 points): no special constraints.
For of the testdata, 。
Translated by ChatGPT 5