No.2381 Gift Exchange Party
Problem Statement
$N$ people have gathered for a gift exchange party. Each person has $1$ gift.
Choose a permutation $(A_1,A_2,\ldots,A_N)$ of $(1,2,\ldots,N)$. Then, perform the following action $P$ times. ($P$ is a prime number.)
- For each $i=1,2,\ldots,N$, the $i$-th person simultaneously gives the gift they are holding to the $A_i$-th person.
After these actions, the gift exchange party is a success if at least $1$ person holds a gift different from the one they initially had, and a failure otherwise.
Find the number of permutations $(A_1,A_2,\ldots,A_N)$ for which the gift exchange party is a success, modulo $998244353$.
Constraints
- $N$ is an integer satisfying $1\le N\le 2\times 10^5$
- $P$ is a prime number satisfying $2\le P\lt 998244353$
Input
$N$ $P$
Output
Output the number of permutations satisfying the condition, modulo $998244353$.
Sample
Sample 1
Input
3 2
Output
2
$(2,3,1)$ and $(3,1,2)$ satisfy the condition.
Sample 2
Input
1 11
Output
0
Sample 3
Input
69403 3001
Output
435305430
Find the answer modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Kazun