摘要: /* ID:chenjiong PROG:sprime LANG:C++*/#include <stdio.h>#include <string.h>#include <math.h>int N;int ans;bool is_prime(int x){ if ( x == 1 ) return false; if ( x == 2 || x == 3 ) return true; if ( x % 2 == 0 ) return false; int i; for ( i = 3; i <= sqrt(... 阅读全文
posted @ 2012-10-26 23:42 Sinker 阅读(152) 评论(0) 推荐(0) 编辑
摘要: hint1就是解决问题的关键:Generate the palindromes and see if they are prime.有目的的生成要比无目的逐一验证更有效率,当然前提是得存在有效的生成方法。/* ID:chenjiong PROG:pprime LANG:C++*/#include <stdio.h>#include <string.h>#include <math.h>const int MAXN = 20000;int palin[MAXN];int cnt;int a,b;void p1(){ palin[cnt++] = 5; pali 阅读全文
posted @ 2012-10-26 23:03 Sinker 阅读(243) 评论(0) 推荐(0) 编辑