#4497. Similar Permutation
0
Similar Permutation
Similar Permutation
题目描述
Below, a permutation of is simply called a permutation. For two permutations , let us define their similarity as the number of integers between and such that:
(A_{i+1}-A_i)(B_{i+1}-B_i)>0.
Find the number, modulo a prime number , of pairs of permutations whose similarity is .
输入格式
The input is given from Standard Input in the following format:
输出格式
Print the answer.
3 1 282282277
16
50 25 998244353
131276976
提示
is a prime number. All values in the input are integers.For instance, below is a pair of permutations that satisfies the condition.
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 and is .
Print the number modulo .
标签: AtCoder|abc282G
来源
AtCoder|abc282G