同样也是HOJ(acm.hit.edu.cn)上有这道题,题号是1004

先生成回文数再判断是否为素数,这样会比较快一些.

我是用字符串模拟来生成回文数的,显得比较笨重.应该可以有数学公式之类的来生成.

比如说两位的回文素数一共有9个,三位的有90个,四位的有90个(利用排列知识可得)

而判素数我也是直接用最原始的方法来做的,如果生成一个素数表的话应该也可以加快程序运行速度.

提取出一年以前写的代码,稍微改了下就交了.

代码写得比较烂,有一百多行.就不贴出来了.



共有3条评论

  1. 贴吧 我快被这道题逼疯了

  2. 呵呵,发你邮箱里了.

  3. 没有啊,糖果?

Leave a Reply

Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).