問題一覧 > 通常問題

No.2679 MODice

レベル : / AI推定難易度 : 500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 146
作問者 : SPD_9X2 / テスター : 👑 tute7627 👑 rin204 だれ kyawa Ayuna
お気に入りにしたユーザー ProblemId : 7069 / 自分の提出
問題文最終更新日: 2024-03-18 14:23:28
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 422 (第1回 競技プログラミング講習会作問企画コンテスト) (順位表) の他の問題:

Problem Statement

You roll $N$ $6$-sided dice. Each die independently shows an integer between $1$ and $6$, inclusive, with equal probability. Find the probability, modulo $\rm{mod}$ $998244353$, that the remainder when the sum of the results is divided by $6$ equals $K$.

More precisely: it can be proved that the desired probability is a rational number. Therefore, it can be expressed as $\frac{P}{Q}$ using coprime integers $P,Q$. Output the integer $R$ between $0$ and less than $998244353$ such that $R \times Q \equiv P \pmod {998244353}$. (It can be proved that $R$ is uniquely determined under the conditions of this problem.)

Input

$N\ K$

  • All inputs are integers
  • $1 \le N \le 10^9$
  • $0 \le K \le 5$

Output

Output the answer on one line.
End the output with a newline.

Sample

Sample 1
Input
1 0
Output
166374059

When rolling $1$ die, the remainder when the result is divided by $6$ is $0$ only if the die shows $6$. The probability of rolling a $6$ is $\frac{1}{6}$.
Since $166374059 \times 6 \equiv 1 \pmod {998244353}$, output $166374059$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。