当前位置:网站首页>7-1 are prime numbers
7-1 are prime numbers
2022-06-11 17:38:00 【Tomatoes_ Menon】
In a given interval [m,n] Inside , Is there a prime p、q、r(p<q<r), bring pq+r、qr+p、rp+q Are prime numbers ?
Input format :
Enter the two endpoints of the given interval 0<m<n≤1000, Separated by spaces .
Output format :
Output the number of prime triples that meet the conditions in one line .
sample input :
1 35
sample output :
10
Example interpretation
Satisfied 10 Group solution is :
2, 3, 5
2, 3, 7
2, 3, 13
2, 3, 17
2, 5, 7
2, 5, 13
2, 5, 19
2, 5, 31
2, 7, 23
2, 13, 17#include<stdio.h>
#include<math.h>
int judge(int m)
{
if (m < 2)
return 0;
for (int i = 2; i <= sqrt(m); i++)
{
if (m % i == 0)
return 0;
}
return 1;
}
int main()
{
int m, n;
int arr[1001];
scanf("%d%d", &m, &n);
int j = 0, flag = 0;
for (int i = m; i <= n; i++)
{
if (judge(i) == 1)
{
arr[j] = i;
j++;
}
}
int x = 0;
for (int p = 0; p < j; p++)
{
for (int q = p + 1; q < j; q++)
{
for (int r = q + 1; r < j; r++)
{
if (judge(arr[p] * arr[q] + arr[r]) == 1 && judge(arr[q] * arr[r] + arr[p]) == 1 && judge(arr[r] * arr[p] + arr[q]) == 1) {
x++;
}
}
}
}
printf("%d\n", x);
return 0;
}
边栏推荐
- QLineEdit 设置输入掩码
- which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
- R language to find missing value location of data set
- Tidb CDC log tables are not eligible to replicate
- Leetcode力扣刷题
- 智能化整体图例,布线、安防、广播会议、电视、楼宇、消防、电气图的图例【转自微信公众号弱电课堂】
- Tidb unsafe recover (tikv downtime is greater than or equal to half the number of replicas)
- [foundation of deep learning] learning of neural network (3)
- tidb-lightning配置数据还原路由
- Foreach traverses collections and collection containers
猜你喜欢

Connect the server with springboard / fortress through xshell

ffmpeg CBR精准码流控制三个步骤

Authing biweekly news: authing forum launched (4.25-5.8)

Authing biweekly news: online application market (5.10-5.22)

Hands on deep learning - multiple input and output channels in the convolution layer

Valid parentheses ---2022/02/23

删除链表的倒数第N个节点---2022/02/22

自动化测试-Selenium

【深度学习基础】神经网络的学习(3)

tidb-写热点的测试及分析
随机推荐
require和ES6 import的区别
合并K个升序链表---2022/02/26
Leetcode force deduction question
Tidb CDC log tables are not eligible to replicate
Typescipt Basics
Merge two ordered linked lists ---2022/02/24
ffmpeg硬编解码 Inter QSV
Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?
Recyclerview cache reuse analysis, source code interpretation
Biden ordered to enforce the zero trust structure
tidb-cdc日志tables are not eligible to replicate
tidb-cdc创建任务报错 Unknown or incorrect time zone
Test basis: black box test
Authing 双周动态:应用市场上线(5 .10 —5 .22 )
05_ Feature Engineering - dimension reduction
6-8 有结构文件的读写1
6-2 多个整数的逆序输出-递归
活动 | Authing 首次渠道合作活动圆满落幕
Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“
Service学习笔记03- 前台服务实战