poj 2262 素数
2013-01-23 10:38
211 查看
题目链接:http://poj.org/problem?id=2262
发现刷题的时候就需要简单难题结合,当难题把自己打击的泄气的时候确实需要这简单的水题哈!
发现刷题的时候就需要简单难题结合,当难题把自己打击的泄气的时候确实需要这简单的水题哈!
#include<iostream> using namespace std; int main() { bool a[1000005]; int i,j,n; for(i=1; i<=1000000; i++) a[i]=true; for(i=2; i<=500000; i++) { j=i+i; while(j<=1000000) { a[j]=false; j+=i; } } while(1) { cin>>n; if(n==0) break; for(i=2; i<=n/2; i++) if(a[i]==true && a[n-i]==true) break; if(i!=n/2+1) cout<<n<<" = "<<i<<" + "<<n-i<<endl; else cout<<"Goldbach's conjecture is wrong."<<endl; } return 0; }
相关文章推荐
- POJ 2262/ ZOJ 1951:Goldbach\'s Conjecture - 筛法打素数表
- poj 2262【素数表的应用---判断素数】【哈希】
- poj2262 筛选法求素数
- POJ 2262 Goldbach's Conjecture(素数筛选法)
- poj_2262 素数打表
- poj 2262 Goldbach's Conjecture 素数筛
- POJ 2262 Goldbach's Conjecture (求解素数的一般筛和线性筛)
- POJ - 2262 - Goldbach's Conjecture(筛选素数)
- POJ 2262 Goldbach's Conjecture 素数筛选
- poj2262 简单素数判定
- POJ 2262 Goldbach's Conjecture (素数判断)
- poj 2262 Goldbach's Conjecture 素数 水题
- POJ 2262 (简单素数判定 ,需要优化)
- 素数水题 POJ 2262 Goldbach's Conjecture
- poj 2262 Goldbach's Conjecture(素数筛选法)
- poj 2262 Goldbach's Conjecture 素数 水题
- POJ 2262 Goldbach's Conjecture(素数表)
- poj2262---素数(质数)的判断
- 【原】 POJ 2262 Goldbach's Conjecture 筛素数 解题报告
- poj 2262 (数论,素数和)