#SP0000012. Những chữ số trong ký ức (Scenes From a Memory)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những chữ số trong ký ức (Scenes From a Memory)
Scenes From a Memory
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
During a hypnosis session, Nicholas recalled a positive integer with decimal digits and no zero digits. He may delete any digits while preserving the relative order of those kept, but must keep at least one digit. He wants the remaining integer to be non-prime (equal to or composite), and wishes to delete as many digits as possible. If several shortest valid remaining sequences exist, print any of them. At least one valid sequence is guaranteed.
Input
The first line contains integer , the number of digits in . The second line contains the -digit string , consisting only of digits 1 through 9.
Output
Print two lines. The first contains integer , the minimum number of retained digits. The second contains the retained sequence of exactly digits, in their original order, representing a non-prime integer.
Subtasks
- Subtask 1 (20 points): , ; all digits of belong to ; a valid non-prime subsequence exists.
- Subtask 2 (30 points): , ; all digits of belong to ; a valid non-prime subsequence exists.
- Subtask 3 (50 points): , ; all digits of belong to ; a valid non-prime subsequence exists.
Examples
Input
3
237
Output
2
27
Explanation
For 237, keeping one digit yields only , or , all prime, so is impossible. Keeping 2 and 7 gives , which is composite. Thus is optimal.
Input
5
44444
Output
1
4
Explanation
Keeping a single digit 4 gives a composite number. Since at least one digit must remain, is optimal.
Input
2
35
Output
2
35
Explanation
Each one-digit subsequence ( or ) is prime. Keeping both produces , which is composite, so the answer has length .