#SP0000219. Đếm số nguyên tố từ mẫu chữ số (Counting dhprime)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm số nguyên tố từ mẫu chữ số (Counting dhprime)
Counting dhprime
Source: LQDOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Turtle has a string containing digits 0 through 9 and the wildcard ?. Each occurrence of ? can be replaced independently with any decimal digit, while every fixed digit is preserved.
After all replacements, the resulting string must represent a valid integer: the first character cannot be 0. Count the replacements that produce a prime number. The positions and order of characters remain unchanged.
Input
One line containing the string , consisting only of digits 0 through 9 and ?.
Output
Print one integer: the number of wildcard replacements producing a valid prime number.
Subtasks
-
Subtask 1 (20 points): ; every character of is in .
-
Subtask 2 (30 points): ; every character of is in .
-
Subtask 3 (50 points): ; every character of is in .
Examples
Input
1?
Output
4
Explanation
Replacing the second character by digits to produces . Exactly , , and are prime. The first digit is always 1, so all four prime-valued replacements are valid. Thus the answer is .