#P5818. [JSOI2011] 同分异构体计数
[JSOI2011] 同分异构体计数
Description
Antonio has recently become interested in organic chemistry, and he wants you to help him quickly compute the number of structural isomers of a certain type of hydrocarbon.
For convenience, we define the following:
- Cycloalkane: A cycloalkane with carbon atoms can be represented as an undirected connected simple graph with vertices and edges (a base cycle plus outward trees). The degree of each vertex is at most .
- M-cycloalkane: A cycloalkane in which at most vertices lie on the cycle. (Note that the cycle must contain at least vertices, because between any two vertices there can be at most edge.)
- Isomorphism: Suppose structures and both have carbon atoms. and are isomorphic if and only if we can label every carbon atom in both and with numbers such that for two carbon atoms labeled and , there is an edge between them in if and only if there is an edge between them in . (In other words, the corresponding graphs of and are isomorphic.)
Now, given and , Antonio wants you to count how many pairwise non-isomorphic M-cycloalkanes with carbon atoms there are. Since this number may be very large, you only need to output it modulo ( is a prime).
In this problem, we do not consider whether a structure can exist stably in chemistry, and we do not consider other types of isomerism.
Input Format
The input contains only one line with three integers , , and , separated by spaces.
Output Format
Output exactly one line: the number of pairwise non-isomorphic M-cycloalkanes with carbon atoms, modulo .
10 10 66103
475
Hint
Constraints
, , , , and is guaranteed to be prime.
Translated by ChatGPT 5
京公网安备 11011102002149号