题意:

就是哥德巴赫猜想。。。任意一个偶数 都可以分解成两个(就是一对啦)质数的加和

输入一个偶数求有几对。。

解析:

首先! 素数打表。。因为 质数 + 质数 = 偶数 所以 偶数 - 质数 = 质数 。。。 我真是蠢啊

还有  vis要用bool类型的!!!!  int会直接爆

代码如下:

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define maxn 10000000
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int LL_INF = 0x7fffffffffffffff,INF = 0x3f3f3f3f;
LL primes[];
bool vis[maxn];
int cnt = ;
void init()
{
mem(vis,);
primes[] = ; primes[] = ;
for(int i=; i<maxn; i++)
if(!vis[i])
{
primes[cnt++] = i;
for(LL j=(LL)i*i; j<maxn; j+=i)
vis[j] = ;
}
} int main()
{
int T;
init();
int res = ;
cin>> T;
while(T--)
{
int ans = ;
int n;
cin>> n;
for(int i=; i<cnt && primes[i] <= n/; i++)
{
if(!vis[n-primes[i]])
ans++;
}
printf("Case %d: %d\n",++res,ans); } return ;
}

Goldbach`s Conjecture LightOJ - 1259 (素数打表 哥德巴赫猜想)的更多相关文章

  1. HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)

    Problem Description Goldbach's Conjecture: For any even number n greater than or equal to 4, there e ...

  2. Lightoj 1370 素数打表 +二分

    1370 - Bi-shoe and Phi-shoe   PDF (English) Statistics   Time Limit: 2 second(s) Memory Limit: 32 MB ...

  3. Light oj-1259 - Goldbach`s Conjecture

                                                                                    1259 - Goldbach`s Co ...

  4. 哥德巴赫猜想-nefu2 & 分拆素数和 hdu2098

    哥德巴赫猜想-nefu2 & 分拆素数和 hdu2098 //哥德巴赫猜想 #include <iostream> #include <cmath> #include ...

  5. LightOJ 1259 Goldbach`s Conjecture 素数打表

    题目大意:求讲一个整数n分解为两个素数的方案数. 题目思路:素数打表,后遍历 1-n/2,寻找方案数,需要注意的是:C/C++中 bool类型占用一个字节,int类型占用4个字节,在素数打表中采用bo ...

  6. LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)

    http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...

  7. Goldbach`s Conjecture(LightOJ - 1259)【简单数论】【筛法】

    Goldbach`s Conjecture(LightOJ - 1259)[简单数论][筛法] 标签: 入门讲座题解 数论 题目描述 Goldbach's conjecture is one of t ...

  8. HDU 1397 Goldbach's Conjecture【素数打表】

    题意:给出n,问满足a+b=n且a,b都为素数的有多少对 将素数打表,再枚举 #include<iostream> #include<cstdio> #include<c ...

  9. LightOJ - 1259 - Goldbach`s Conjecture(整数分解定理)

    链接: https://vjudge.net/problem/LightOJ-1259 题意: Goldbach's conjecture is one of the oldest unsolved ...

随机推荐

  1. SkylineGlobe 6.6 三维地图上实现自定义右键菜单示例代码

    1.OnRButtonDown.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

  2. 浅谈Java泛型中的extends和super关键字

    泛型是在Java 1.5中被加入了,这里不讨论泛型的细节问题,这个在Thinking in Java第四版中讲的非常清楚,这里要讲的是super和extends关键字,以及在使用这两个关键字的时候为什 ...

  3. 搭建SSH服务

    1.安装 ssh-server 通过命令进行安装:sudo apt-get install openssh-server 在安装时遇到问题,根据提示,执行命令:sudo apt-get update, ...

  4. sql函数创建

    语法: CREATE [OR REPLACE] FUNCTION function_name (arguments) RETURNS return_datatype AS $variable_name ...

  5. POJ3714 Raid 分治/K-D Tree

    VJ传送门 简要题意:给出两个大小均为\(N\)的点集\(A,B\),试在\(A\)中选择一个点,在\(B\)中选择一个点,使得它们在所有可能的选择方案中欧几里得距离最小,求出这个距离 下面给出的两种 ...

  6. Spring Boot Admin 日志查看功能

    按照官方配置POM和配置文件后,能够结合Eureka查看各微服务状态,但是日志始终查看不了,出现406等错误. 最后偶然发现,是在在从官方网站拷贝配置的时候,出现的问题. logging.file=* ...

  7. Cordova套网站

    用Cordova套网站,只修改Content的话,打包后的App,在点击后会打开浏览器,并没有在App中显示内容. 需要设置allow-navigation为 * <?xml version=' ...

  8. 生成32位UUID及生成指定个数的UUID

    参考地址:https://blog.csdn.net/xinghuo0007/article/details/72868799 UUID是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯 ...

  9. item 10: 比起unscoped enum更偏爱scoped enum

    本文翻译自modern effective C++,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 一般情况下,在花括号中声明一个name(包括变量名,函数名),这个 ...

  10. 【转载】固态硬盘的S.M.A.R.T详解

    文章来源于: 瑞耐斯存储技术 兵哥写这篇文章,是因为在测试的过程中看到了 SSD存在偶尔有性能下降的情况,经分析为S.M.A.R.T命令所导致,虽然这种情况看似不严重,但如果应用在诸如数据采集等关键性 ...