字母算术素数AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given a string $S$ consisting of lowercase English letters. If there exists a prime number $P$ satisfying the following condition, find one such $P$.
给定一个由小写英文字母组成的字符串 $S$。如果存在满足以下条件的素数 $P$,请找出其中任意一个。AI (CI翻译)
Condition: Let $T$ be the string representing $P$ in decimal notation without an extra leading 0. Then, $|S|=|T|$, and for every $1\leq i< j \leq |S|$, we have $S_i=S_j$ if and only if $T_i=T_j$.
条件:令 $T$ 表示 $P$ 的十进制表示,且不含额外的前导 0。则 $|S|=|T|$,并且对于任意 $1\leq i< j \leq |S|$,当且仅当 $S_i=S_j$ 时,有 $T_i=T_j$。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$S$is a string of length between$1$and$7$(inclusive) consisting of lowercase English letters.
$S$是一个长度在$1$到$7$(含)之间、由小写英文字母组成的字符串。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
S
SAI (CI翻译)
Output
输出格式
AI (CI翻译)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.
如果不存在满足题目描述中条件的素数,输出 -1。
如果存在这样的素数,输出其中任意一个。如果有多个答案,输出其中任意一个都将被接受。AI (CI翻译)
样例
motor
10607
byebye
-1
coconut
1010237
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。