当前位置:网站首页>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);
}
边栏推荐
- C escape character
- Yiwei lithium energy plans to raise 9billion yuan: liujincheng and luojinhong jointly subscribe for 6billion yuan of layout Optical Valley
- 指针相关概念
- MAT的安装和使用
- FIRSTVT和LASTVT白话版
- Prompt that the program cannot access key files / directories when installing PS software. Error code: 41
- 阿裏、騰訊、拼多多垂範,產業互聯網的新邏輯漸顯
- 【LDA】EM变分推理 粗略版笔记【待完善
- 增加mysql的最大连接数
- JUnit exception, a method that asserts that the exception information is not empty
猜你喜欢
随机推荐
Thinking: what is asynchrony and thread safety
idea 拉取分支代码
USART(RS232422485)、I2C、SPI、CAN、USB总线
数组相关内容
Yiwei lithium energy plans to raise 9billion yuan: liujincheng and luojinhong jointly subscribe for 6billion yuan of layout Optical Valley
IMU的学习记录
浏览器指纹解读
C 操作符
C 数据类型
Function recursion example
xshell 7 官网免费下载
Dataset and dataframe in sparksql
Data collection
Prompt that the program cannot access key files / directories when installing PS software. Error code: 41
Selenium advanced
tc菜单分割
PTA:自测-2 素数对猜想 (20分)
ES6新特性
[system. Currenttimemillis()] current timestamp: the number of milliseconds that have elapsed since the current system time was 0:00:00 on January 1, 1970
Wild pointer understanding







