| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 512 MB | 25 | 15 | 10 | 55.556% |
A correct parentheses sequence can be defined recursively as follows:
(X)$ is a correct sequence.Each correct parentheses sequence can be derived using the above rules.
For a parentheses sequence, you can make some operations with it.
(' in the specified range changes to a ')' and vice versa.The value of a parentheses sequence is the minimal number of the operations required to change it into a correct parentheses sequence. If it is impossible, the value of the sequence is equal to 10ドル^{100}$.
For example, the value of "()((" is 1ドル,ドル the value of "()()" is 0ドル,ドル and the value of "(((" is 10ドル^{100}$.
You are given an integer $n$. For each 1ドル \le i \le n,ドル find the number $A_i$ of different parentheses sequence of length $n$ which has value $i,ドル and then calculate the sum $\sum_{i = 0}^{n} ((i + 1) \cdot A_i)$.
The answer may be very large, so print it modulo the given integer $m$.
The first line of the input contains two integers $n$ and $m$ (1ドル \le n \le 10^6,ドル 1ドル \le m \le 10^9$).
Print one integer: the answer to the problem.
1 100
0
10 100
68