题目描述
Problem Description
Reminiscing about the times with Yu. Since Yu is a playful girl, they have many toys, one of which is a toy resembling a white dragonfly. Now, there are $n$ such white dragonflies left with Rem, with wing lengths of $1, 2, \dots, n$, respectively, and each can be spread to any angle between $(0, \pi)$. Rem believes that the scene where $m$ white dragonflies are spread to make the distances between their wing tips integers and distinct is akin to weaving a memory. He considers two memories identical if and only if the $m$ white dragonflies can be rearranged in a way that pairs correspond to each other with equal wing lengths and distances between wing tips. He wants to know how many different memories can be woven. You only need to find the value of the answer $\bmod{p}$.
Input Format
A single line containing three positive integers $n, m, p$.
Output Format
A single line with one number, representing the answer.
Sample Input and Output
Sample Input #1
32 2 47
Sample Output #1
36
Sample Input #2
233 223 1926817
Sample Output #2
620162
Sample Input #3
3 1 7
Sample Output #3
2
Notes/Hints
Simplified Problem Statement
Find the number of different isosceles triangles with leg lengths $1 \le a \le n$ and base lengths $1 \le b \le 2a-1$, both being integers, with distinct leg lengths and base lengths, for $m$ triangles. Two sets are considered identical if and only if the $m$ triangles can be rearranged in a way that pairs correspond exactly.
Sample Explanation:
Due to space limitations, only the explanation for Sample #3 is provided.
Nine different memories can be woven: $1,1,1$, $2,2,1$, $2,2,2$, $2,2,3$, $3,3,1$, $3,3,2$, $3,3,3$, $3,3,4$, $3,3,5$. After taking modulo $7$, the result is $2$.
This problem uses bundled testing, with the scores and constraints for each Subtask as follows:
| Subtask No. | $m \le n \le$ | Special Constraints | Score |
|---|---|---|---|
| $1$ | $10^3$ | None | $13$ |
| $2$ | $10^6$ | None | $37$ |
| $3$ | $10^{18}$ | None | $37$ |
| $4$ | $10^{18}$ | $p$ is a prime number | $13$ |
For all data, $1 \le m \le n \le 10^{18}, 1 \le p \le 10^5$, and $p$ is not guaranteed to be a prime number.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分