CF724F.Uniformly Branched Trees

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A tree is a connected graph without cycles.

Two trees, consisting of n vertices each, are called isomorphic if there exists a permutation p: {1, ..., n} → {1, ..., n} such that the edge (u, v) is present in the first tree if and only if the edge (p__u, p__v) is present in the second tree.

Vertex of the tree is called internal if its degree is greater than or equal to two.

Count the number of different non-isomorphic trees, consisting of n vertices, such that the degree of each internal vertex is exactly d. Print the answer over the given prime modulo mod.

树是无环的连通图。

由 nn 个顶点构成的两棵树被称为同构的,若存在一个置换 p:{1,…,n}→{1,…,n}p:\{1,\dots,n\}\to\{1,\dots,n\},使得边 (u,v)(u,v) 在第一棵树中存在当且仅当边 (pu,pv)(p_u,p_v) 在第二棵树中存在。

树的一个顶点称为内部顶点,当且仅当它的度数大于等于 22。

计算满足以下条件的互不同构的树的数目:该树恰含 nn 个顶点,且每个内部顶点的度数恰好为 dd。将答案对给定的素数模 modmod 取模后输出。

输入格式

The single line of the input contains three integers n, d and mod (1 ≤ n ≤ 1000, 2 ≤ d ≤ 10, 108 ≤ mod ≤ 109) — the number of vertices in the tree, the degree of internal vertices and the prime modulo.

输入仅包含一行,三个整数 nn、dd 和 modmod(1 ≤ n ≤ 10001 ≤ n ≤ 1000,2 ≤ d ≤ 102 ≤ d ≤ 10,108 ≤ mod ≤ 10910^8 ≤ mod ≤ 10^9)—— 分别表示树的顶点数、内部顶点的度数以及模数(质数)。

输出格式

Print the number of trees over the modulo mod.

在模 mod 意义下输出树的个数。

输入输出样例

  • 输入#1

    5 2 433416647

    输出#1

    1
  • 输入#2

    10 3 409693891

    输出#2

    2
  • 输入#3

    65 4 177545087

    输出#3

    910726

输入解题思路,AI测评打分。不知道怎么写?

首页