No.2679 MODice
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
SPD_9X2
tute7627
だれ
kyawa
Ayuna