No.1747 Many Formulae 2
Problem Statement
You are given a string $S$ consisting only of 1 ~ 9.
You may insert $0$ or more + between adjacent characters of this string. However, + must not be consecutive.
Consider regarding the resulting string as a formula and calculating its value.
Among the possible strings, how many have a prime value when evaluated as a formula?
Input
$S$
- $1\leq |S|\leq 10$
- $S$ consists only of
1~9
Output
Output the answer on one line.
Sample
Sample 1
Input
124
Output
1
The possible strings are the $4$ strings 124 1+24 12+4 1+2+4, whose values are $124,25,16,7$, respectively.
Among these, only $7$ is prime, so output $1$.
Sample 2
Input
4643
Output
8
All of the values are prime.
Sample 3
Input
9999999999
Output
0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
だれ
hir355
nok0
kaikey
ぷら