[搜寻]USACO-1.5-Prime Palindromes

[搜索]USACO-1.5-Prime Palindromes
[搜寻]USACO-1.5-Prime Palindromes

Prime Palindromes

The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes in the range of two supplied numbers a and b (5 <= a < b <= 100,000,000); both a and b are considered to be within the range .

PROGRAM NAME: pprime

INPUT FORMAT

Line 1: Two integers, a and b

SAMPLE INPUT (file pprime.in)

5 500

OUTPUT FORMAT

The list of palindromic primes in numerical order, one per line.

SAMPLE OUTPUT (file pprime.out)

5
7
1
1 101
151
131 181
353
191 313 373
383

给定一个范围,输出在这个范围内(包含边界)的所有回文素数.
注意以后有回文数的情况,尽量先用DFS生成回文数表,然后在做处理,不要去枚举产生回文数.
这里打出回文数表以后先排序,然后二分查出上下界,把该范围中的所有素数输出即可。

代码: