AT_abc475_d.Alphametic Prime
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
Condition: Let T be the string representing P in decimal notation without an extra leading 0. Then, ∣S∣=∣T∣, and for every 1≤i<j≤∣S∣, we have Si=Sj if and only if Ti=Tj.
给你一个由小写英文字母组成的字符串 S。如果存在一个满足以下条件的质数 P,请找出一个这样的 P。
条件:设 T 为 P 在十进制表示下(不含前导零)所对应的字符串。则需满足 ∣S∣=∣T∣,且对任意 1≤i<j≤∣S∣,均有 Si=Sj 当且仅当 Ti=Tj。
输入格式
The input is given from Standard Input in the following format:
S
输入从标准输入中以如下格式给出:
S
输出格式
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。
如果存在,输出任意一个满足条件的素数。若存在多个解,输出其中任意一个即可。
输入输出样例
输入#1
motor
输出#1
10607
输入#2
byebye
输出#2
-1
输入#3
coconut
输出#3
1010237
说明/提示
Sample 1 Explanation:
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.
Sample 2 Explanation:
If there is no prime number satisfying the condition, output -1.
Constraints
- S is a string of length between 1 and 7 (inclusive) consisting of lowercase English letters.
样例 1 解释:
除此之外,例如输出 40709 也是可接受的。然而,例如 81817 不满足条件,因此不可接受。
样例 2 解释:
若不存在满足条件的素数,则输出 -1。
限制条件
- S 是一个由小写英文字母组成的字符串,其长度在 1 到 7(含)之间。
输入解题思路,AI测评打分。不知道怎么写?