問題一覧 > 通常問題

No.2381 Gift Exchange Party

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 113
作問者 : 👑 箱星 / テスター : 👑 Kazun
お気に入りにしたユーザー ProblemId : 9491 / 自分の提出
問題文最終更新日: 2023-05-19 20:21:03
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 397 (群論コンテスト) (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。