東京海上日動プログラミングコンテスト2023(AtCoder Beginner Contest 299)
Ex
Dice Sum Infinity
AtCoder
⌀ 2984
原题
←G →
翻译中…

Problem Statement

翻译中…

Takahashi has an unbiased six-sided die and a positive integer $R$ less than $10^9$. Each time the die is cast, it shows one of the numbers $1,2,3,4,5,6$ with equal probability, independently of the outcomes of the other trials.

翻译中…

Takahashi will perform the following procedure. Initially, $C=0$.

翻译中…
  1. Cast the die and increment $C$ by $1$.
  2. Let $X$ be the sum of the numbers shown so far. If $X-R$ is a multiple of $10^9$, quit the procedure.
  3. Go back to step 1.
翻译中…

Find the expected value of $C$ at the end of the procedure, modulo $998244353$.

翻译中…

Note

翻译中…

Under the constraints of this problem, it can be shown that the expected value of $C$ is represented as an irreducible fraction $p/q$, and there is a unique integer $x\ (0\leq x\lt998244353)$ such that $xq \equiv p\pmod{998244353}$. Print this $x$.

翻译中…

Constraints

翻译中…
  • $0\lt R\lt10^9$
  • $R$ is an integer.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

R

翻译中…

Output

翻译中…

Print a single line containing the answer.

翻译中…

样例

Input #1
1
Output #1
291034221
The expected value of $C$ at the end of the procedure is approximately $833333333.619047619$, and $291034221$ when represented modulo $998244353$.
Input #2
720357616
Output #2
153778832
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。