Rikka with Composite Number
题号:NC213962
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

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 and integer c = 0, and then generates in turns. In each turn:
  1. Rikka selects a digit d from D uniformly at random, and then changes c to ;
  2. If c has already been a composite integer, Rikka takes c as the result. Otherwise, Rikka returns to Step 1 and starts a new 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 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 , you need to output .
示例1

输入

复制
100000000

输出

复制
3

说明

The generator must return 111 in the third turn.
示例2

输入

复制
001100000

输出

复制
499122178

说明

There are 3 possibilities:
1. Return 4 in the first turn, with probability \frac{1}{2}.
2. Return 33 in the second turn, with probability \frac{1}{4}.
3. Return 34 in the second turn, with probability \frac{1}{4}.
Therefore, the expected number of turns is \frac{3}{2}.