题目描述:
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 .
输入输出格式:
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 11 101 131 151 181 191 313 353 373 383
题目大意:
写一个程序找出a到b(5 <= a < b <= 100,000,000),即是素数又是回文数的数,比如151即是素数又是回文数。
解题思路:
很容易想到就是暴力破解,代码也很容易写出来,但是,请注意题目要求在1s内跑出来,这其实是难为我了,可以看到下面两段代码,第一段是用python写的,第二段使用c++来写的,第一段我提交后运行,果然结果是超时,第二段运行时间很短,说