HHKBプログラミングコンテスト2022 Winter(AtCoder Beginner Contest 282)
G
Similar Permutation
AtCoder
⌀ 2412
原题
← Ex→
翻译中…

Problem Statement

翻译中…

Below, a permutation of $(1,2,\ldots,N)$ is simply called a permutation.

翻译中…

For two permutations $A=(A_1,A_2,\ldots,A_N),B=(B_1,B_2,\ldots,B_N)$, let us define their similarity as the number of integers $i$ between $1$ and $N-1$ such that:

翻译中…
  • $(A_{i+1}-A_i)(B_{i+1}-B_i)>0$.
翻译中…

Find the number, modulo a prime number $P$, of pairs of permutations $(A,B)$ whose similarity is $K$.

翻译中…

Constraints

翻译中…
  • $2\leq N \leq 100$
  • $0\leq K \leq N-1$
  • $10^8 \leq P \leq 10^9$
  • $P$ is a prime number.
  • All values in the input are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N K P

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3 1 282282277
Output #1
16
For instance, below is a pair of permutations that satisfies the condition. - $A=(1,2,3)$ - $B=(1,3,2)$ Here, we have $(A_2 - A_1)(B_2 -B_1) > 0$ and $(A_3 - A_2)(B_3 -B_2) < 0$, so the similarity of $A$ and $B$ is $1$.
Input #2
50 25 998244353
Output #2
131276976
Print the number modulo $P$.
题目信息
题号
abc282_g
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。