#P10375. [AHOI2024 初中组 / 科大国创杯初中组 2024] 计数
[AHOI2024 初中组 / 科大国创杯初中组 2024] 计数
Background
The testdata for this problem is not official.
Official testdata (that can be uploaded here) is being collected.
Official testdata (that cannot be uploaded here): https://www.luogu.com.cn/training/499869
Unofficial testdata download: https://scg3.piaoztsdy.cn/training/69bce235a7cf509104565c83
Problem Description
Xiao Keke had a dream. In the dream, there are candies from left to right. Each candy has a color, represented by a positive integer in .
Each time, Xiao Keke chooses two candies with the same color, and eats them as well as all candies between them.
Xiao Keke remembers that for the candy sequence in the dream, there exists a way to eat all candies.
After waking up, Xiao Keke forgot what the candy sequence in the dream was. Can you help her count, among all possible candy sequences, how many sequences could have appeared in her dream (that is, there exists a way to eat them all)?
Since the answer may be very large, you only need to output it modulo .
Input Format
One line with two positive integers .
Output Format
One line with one non-negative integer, the answer modulo .
3 2
4
6 3
405
30 2
73741759
100 100
566607183
Hint
Explanation for Sample 1
There are valid candy sequences in total: , , , .
Constraints
For of the testdata, , .
For of the testdata, , .
For another of the testdata, , .
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5