当前位置:网站首页>Pta: self test -2 prime pair conjecture (20 points)
Pta: self test -2 prime pair conjecture (20 points)
2022-06-12 14:59:00 【George Sumu】

The basic idea : Find all prime pairs first , Then go through it to see how many pairs there are .
#include"stdio.h"
#include"math.h"
#include <cstdlib>
#include <iostream>
#include <queue>
using namespace std;
int sushu(int n)
{
int i=2;
if(n<2) return 0;
for(;i<=sqrt(n);i++){
if(n%i==0){
return 0;
}
}
return 1;
}
int main(){
queue<int> q;
int n =0;
scanf("%d",&n);
int m =0;
int s = 2;
for (int i=3;i<=n;i++){
if(sushu(i) == 1){
if((i-s) == 2){
m++;
}
s =i;
}
}
printf("%d",m);
}
边栏推荐
猜你喜欢

sql跨库注入

安凯微电子冲刺科创板:年营收5亿 小米产业基金是股东

Yiwei lithium energy plans to raise 9billion yuan: liujincheng and luojinhong jointly subscribe for 6billion yuan of layout Optical Valley

MAT的安装和使用

Selenium advanced

Element positioning of selenium

selenium-webdriver之断言

Autofac初学(1)

Detailed explanation of factory pattern (simple factory pattern, factory method pattern, abstract factory pattern) Scala code demonstration

野指针理解
随机推荐
C escape character
三维重建系统 | L3增量运动恢复结构(增量SFM)
增加mysql的最大连接数
阿里建议所有 POJO 类属性使用包装类,但这些坑你有注意到吗?
Left aligned, right aligned, random number, goto, compare output bool
C 数据类型
【LDA】EM变分推理 粗略版笔记【待完善
Industrial end: a new battlefield of 618
产业端:618的新战场
ShardingSphere实践(6)——弹性伸缩
学习是一件逆人性的事情(成为高手的内功心法)
Yiwei lithium energy plans to raise 9billion yuan: liujincheng and luojinhong jointly subscribe for 6billion yuan of layout Optical Valley
NETCORE combined with cap event bus to realize distributed transaction -- Introduction (1)
解决log4j2漏洞遭到挖矿、僵尸进程病毒攻击
Autofac Beginner (1)
结构体示例
ADSL
基于TensorRT的深度学习模型部署实战教程!
selenium之元素定位
selenium-webdriver之断言