問題一覧 > 通常問題

No.1747 Many Formulae 2

レベル : / AI推定難易度 : 525 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 190
作問者 : だれ / テスター : hir355 nok0 kaikey ぷら
お気に入りにしたユーザー ProblemId : 7281 / 自分の提出
問題文最終更新日: 2026-04-28 14:42:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 323 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。