#Lutece3222. 随机的树
随机的树
Migrated from Lutece 3222 随机的树
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Tag: Symbolic Method
考虑这样一种随机生成 个点的有根树的方式:
- 以 为根,对于 ,在 中均匀随机一个点作为 的父亲。
只生成一棵树太简单了,现在问按此方式随机生成 颗 个点的有根树,他们两两同构的概率是多少,对 取模。
两棵 个点的有根树 同构当且仅当存在一个长为 的排列 ,满足 ,且 , 在 中的父亲是 ,则在 中 的父亲是 。
Input
第一行三个正整数 ,表示点数,树的个数和模数。
Output
一行一个正整数表示答案。
Samples
2 2 998244353
1
3 2 998244353
499122177
4 2 998244353
332748118
10 2 998244353
113919852
50 233 998244353
634280054
Constraints
且 是质数。
Resources
2024 UESTC ICPC Training for Math