#P1218. [USACO1.5] 特殊的质数肋骨 Superprime Rib
[USACO1.5] 特殊的质数肋骨 Superprime Rib
Description
Farmer John’s cows always produce the best ribs. You can recognize them by the numbers stamped on each rib by Farmer John and the USDA.
Farmer John is sure he sells genuine superprime ribs because, starting from the right and removing one rib at a time, the digits on the ribs that remain always form a prime number.
For example: for , the digits of all ribs form a prime; with three ribs it is still prime; with two ribs it is prime; and, of course, the last rib is also prime. is called a superprime of length .
Write a program that, given the number of ribs , finds all superprimes of length . is not a prime.
Input Format
A single line containing a positive integer .
Output Format
Output, in increasing order, all superprimes of length , one per line.
4
2333
2339
2393
2399
2939
3119
3137
3733
3739
3793
3797
5939
7193
7331
7333
7393
Hint
Constraints
For of the testdata, .
Problem translation from NOCOW.
USACO Training Section 1.5.
Translated by ChatGPT 5
京公网安备 11011102002149号