poj2909 || poj2262】的更多相关文章

#include <stdio.h> #include <stdlib.h> #include<math.h> int isPri(int a, int b) { int i; ; i <= sqrt(a); i++) { ) ; } ; i <= sqrt(b); i++) { ) ; } ; } int main() { int n,flag,i,cout; while(scanf("%d",&n) != EOF &&…
poj2262 Goldbach's Conjecture 用欧拉筛把素数筛出来,再枚举一下. #include<iostream> #include<cstdio> #include<cstring> #define re register using namespace std; #define N 1000001 int n,v[N],pri[N],cct; bool is[N]; int main(){ ;i<N;++i){ ; ;j<=cct;++…
Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 48161   Accepted: 18300 Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conject…
Goldbach's Conjecture   Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture: Every even number greater than 4 can be written as the sum of two odd prime nu…
                                                                                               Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 36877   Accepted: 14119 Description In 1742, Christian Goldbach, a Germa…
这两道题都是哥赫巴德猜想的内容.基本的技术点都是在一个很大的数字范围里面求质数.直接判断两个数是不是质数,这种方法虽然可行但是还是很慢的.所以这两题我们使用打表! 而建立质数表的方法就是筛法求质,速度很快(O(nlogn)),思想很简单,就是在把这个范围的数全部列出来,然后从2开始依次把2的倍数删掉,然后前进一个数,此时是3,然后把3的倍数再全部删去,就这样依次前进.知道把这个数表处理完毕,就得到了这个数表范围内的质数. 代码如下: ]={}; table[]=table[]=; ;i<;i++…
In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture: Every even number greater than 4 can be written as the sum of two odd prime numbers. For example: 8 = 3 + 5. Both…
For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2 This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one…
题目:http://poj.org/problem?id=2262 水水更健康~ 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; int const maxn=1e6; ],cnt; ]; void init() { ;i<=maxn;i++) { if(!vis[i])pri[++cnt]=i; ;j<=cnt&&i*pri[j…
刚刚学了一种新的素数筛选法,效率比原先的要高一些,据说当n趋近于无穷大时这个的时间复杂度趋近O(n).本人水平有限,无法证明. 这是道水题,贴代码出来重点是欧拉筛选法.我把原来普通的筛选法贴出来. //2013-11-07-22.30 //poj 2909 #include <stdio.h> #include <string.h> const int maxn = (1<<15)+5; bool vis[maxn]; int pr[3416]; int cnt = 1…