PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000152. Số nguyên tố mang mẫu chữ cái (Alphametic Prime)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số nguyên tố mang mẫu chữ cái (Alphametic Prime)
Alphametic Prime
Source: AtCoder — abc475_d
Version: Phước Hưng OJ Extended; one input file per judge run.
Problem Statement
Given a lowercase string of length at most 7, find a prime with the same length and exactly the same equality pattern among digit positions as among letters of . Print any valid prime, or -1 if impossible.
Input
One lowercase string .
Output
Print any matching prime, or -1.
Subtask
- Subtask 1 (20 points): , lowercase English letters.
- Subtask 2 (30 points): , lowercase English letters.
- Subtask 3 (50 points): , lowercase English letters.
Example
Input
motor
Output
10607
Explanation
The example follows the mathematical conditions and the specified output format.