| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB | 3 | 2 | 2 | 66.667% |
You are given a positive integer $N,ドル find the expected length of the minimum cycle in permutation of integers from 1ドル$ to $N$. All permutations are equiprobable.
Consider the answer is an irreducible fraction $\frac{A}{B}$. Output $A \cdot B^{-1} \mod P,ドル where $P$ is a given prime number. It is guaranteed that $gcd(B, P) = 1$.
The only line of input contains two integers $N$ and $P$ (1ドル \le N \le 10^4,ドル 10ドル^4 < P \le 10^9 + 33$). It's guaranteed that $P$ is a prime number.
Output the answer to the problem in a single line.
2 1000000007
500000005
3 1000000007
666666673