Project Euler problem 37
来源:互联网 发布:程序员屏幕设置 编辑:程序博客网 时间:2024/06/05 03:30
试探性的筛了个500W素数表
然后一个一个素数的试了试
11个都给找出来了
最大的也就70多W
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <set>#include <stack>#include <cmath>#include <map>#include <ctime>#define MAXN 111111#define INF 100000007using namespace std;bool tag[5000001];int p[3000001];int cnt;void get_prime(){ cnt = 0; tag[1] = 1; for (int i = 2; i < 5000000; i++) { if (!tag[i]) p[cnt++] = i; for (int j = 0; j < cnt && p[j] * i < 5000000; j++) { tag[i*p[j]] = 1; if (i % p[j] == 0) break; } }}bool gao(int x){ int tx = x; while(tx) { if(tag[tx]) return 0; tx /= 10; } tx = x; int ten = 1; while(ten <= tx) ten *= 10; ten /= 10; if(ten == 1) return 0; while(1) { if(tag[tx]) return 0; if(tx < 10) break; tx = tx % ten; ten /= 10; } return 1;}int main(){ get_prime(); int ans = 0; for(int i = 0; i < cnt; i++) if(gao(p[i])) cout << p[i] << endl; cout << ans << endl; return 0;}
- Project Euler problem 37
- Project Euler:Problem 37 Truncatable primes
- Euler Project Problem 6
- project euler problem 11
- Project Euler Problem 81
- Project Euler Problem 60
- Project Euler Problem 59
- Project Euler Problem 58
- Project Euler Problem 57
- Project Euler Problem 16
- Project Euler Problem 30
- Project Euler Problem 31
- Project Euler Problem 32
- Project Euler Problem 14
- Project Euler Problem 15
- Project Euler Problem 17
- Project Euler - Problem 18
- Project Euler - Problem 67
- 黑马程序员--XML添加读取删除的实现
- C++默认构造函数——深入理解
- magento 获取自定义产品属性和属性值
- Dom4j 学习资料
- google的站内搜索
- Project Euler problem 37
- github出错处理
- Android declare-styleable:自定义控件的属性(attr.xml,TypedArray)的使用
- 提高自己的职业技能:性能测试
- [10月1日的脚本] 移除Windows8应用商店中的应用程序
- 求二叉树的“胖”度
- C++:静态联编和动态联编
- POJ 1470 LCA
- c++中的显示转换