No.2068 Restricted Permutation
Problem Statement
For a permutation $P$ of length $N$, define $f(P)$ as the number of permutations of length $N$ that come before $P$ in lexicographical order.
There are $(N-1)!$ permutations $P$ of length $N$ satisfying $P_K=X$. Compute $f(P)$ for each of them and find the sum of these values.
Since the sum can be very large, output it modulo $998244353$.
▶What is a permutation of length $N$?
It refers to a rearrangement of $(1,2,\ldots,N)$.
▶What does it mean to come before in lexicographical order?
For permutations $P,Q$ of length $N$, $P$ comes before $Q$ if there exists an $i$ such that $P_i\neq Q_i$ and, letting $j$ be the smallest such $i$, we have $P_j < Q_j$.
Input
$N\ K\ X$
Output
Compute $f(P)$ for all permutations $P$ of length $N$ satisfying $P_K=X$, and output the sum of these values modulo $998244353$.
Sample
Sample 1
Input
3 2 1
Output
6
The permutations $P$ satisfying the condition are $P=(2,1,3),(3,1,2)$, for which $f(P)=2,4$ respectively. Therefore, output their sum, $6$.
Sample 2
Input
4 4 4
Output
42
Sample 3
Input
100 1 3
Output
967152772
Output the answer modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
SSRS
とりゐ