시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 8 | 6 | 6 | 75.000% |
Rikka is a professional problem setter. Today, she is going to generate test cases for a problem about Composite Number.
To randomly generate composite numbers, Rikka starts from a non-empty subset $D$ of digits $\{1,2,\dots, 9\}$ and integer $c = 0$, and then generates in turns. In each turn:
The time cost of a generator is crucial. Therefore, Rikka wants you to calculate the expected number of the turns used by the generator to generate a composite number.
A positive integer $n$ is a composite integer if and only if there exists an integer $k \in [2, n - 1]$ satisfying $k$ is a factor of $n$.
The first line contains a $01$-string of length $9$. The $i$-th character is $1$ if and only if digit $i$ is inside $D$.
The input guarantees that $D$ is not empty.
Output a single integer, representing the expected number of turns.
The answer is guaranteed to be a rational number. You are required to output the answer module $998244353$. Formally, if the simplest fraction representation of the answer is $\frac{x}{y}$, you need to output $x \times y^{998244351} \text{ mod } 998244353$.
100000000
3
001100000
499122178
For the first sample, the generator must return $111$ in the third turn.
For the second sample, there are $3$ possibilities:
Therefore, the expected number of turns is $\frac{3}{2}$.