poj2262
来源:互联网 发布:倩女幽魂手游数据互通 编辑:程序博客网 时间:2024/05/26 22:57
#include <iostream>#include <stdio.h>#include <cmath>#include <memory.h>using namespace std;int main(){ bool a[1000005],p[1000005]; int i,j,n; // freopen("in.txt","r",stdin); memset(a,true,sizeof(a)); memset(p,false,sizeof(p)); for (i=2;i<1000005;i++) if (a[i]) { p[i]=true; for (j=i;j<1000005;j+=i) a[j]=false; } // for (i=1;i<=1000005;i++) if (p[i]) cout<<i<<" "; cin>>n; while (n>0) { for (i=2;i<=n/2;i++) if ((p[i])&&(p[n-i])) { cout<<n<<" = "<<i<<" + "<<n-i<<endl; break; } cin>>n; } return 0;}
题目大意就是输入一个不小于6的合数,把它表示成两个质数的和,如果有多个,数出相差最大的一组这题就是简单的枚举+素数判定
0 0
- POJ2262
- poj2262
- poj2262
- poj2262
- poj2262
- poj2262
- poj2262
- POJ2262
- poj2262
- poj2262
- POJ2262
- poj2262
- poj2262
- poj2262
- POJ2262
- Poj2262
- poj2262 Goldbach's Conjecture
- POJ2262 Goldbach's Conjecture
- 为数字千分位加点 -- Web前端面试经验
- 【BZOJ 1876】 [SDOI2009]SuperGCD
- bat更换IP地址
- 关于Unable to start activity ComponentInfo异常
- 成为更加优秀的程序员的10个要点
- poj2262
- poj2386
- Eclipse自动生成方法注释 快捷键
- 4/19
- MySQL错误:Can't Connect to(10060)
- Fresco源码解析 - Hierarchy / View / Controller
- [Leetcode 125, easy] Valid Palindrome
- 蓝桥杯:基础练习 杨辉三角形【JAVA算法实现】
- poj2388