专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 编程

[搜寻]USACO-1.5-Prime Palindromes

发布时间:2011-07-01 07:31:04 文章来源:www.iduyao.cn 采编人员:星星草
[搜索]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生成回文数表,然后在做处理,不要去枚举产生回文数.
这里打出回文数表以后先排序,然后二分查出上下界,把该范围中的所有素数输出即可。

代码:


友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: