#ABC475D. 字母算式素数 / Alphametic Prime
字母算式素数 / Alphametic Prime
Problem Statement
You are given a string consisting of lowercase English letters. If there exists a prime number satisfying the following condition, find one such .
Condition: Let be the string representing in decimal notation without an extra leading 0. Then, , and for every , we have if and only if .
Constraints
- is a string of length between and (inclusive) consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
If there is no prime number satisfying the condition in the problem statement, output -1.
If one exists, output one such prime number. If there are multiple solutions, any of them will be accepted.
motor
10607
Besides this, for example, outputting 40709 would also be accepted. However, for example, 81817 does not satisfy the condition, so it would not be accepted.
byebye
-1
If there is no prime number satisfying the condition, output -1.
coconut
1010237
- Source: AtCoder ABC 475 D
相关
在下列比赛中: