当前位置:网站首页>All in one 1405: sum and product of prime numbers
All in one 1405: sum and product of prime numbers
2022-07-06 12:57:00 【Studying hard】
【 Title Description 】
The sum of two prime numbers is S, What is the maximum product of them ?
【 Input 】
One is not greater than 10000 The positive integer S, Is the sum of two prime numbers .
【 Output 】
An integer , Is the maximum product of two prime numbers . The data is guaranteed to have a solution .
【 sample input 】
50
【 sample output 】
589
#include<stdio.h> int main() { int a[10001],b[10001]; a[0] = 2; int i, j; int count = 1; for (i = 3; i <= 9999; i += 2) { for (j = 3; j <= i; j += 2) { if (i % j == 0) { break; } } if (i == j) { a[count] = i; count++; } } for (i = 0; i < count; i++) { b[i] = a[i]; } int n; scanf("%d", &n); int num = 0; for (i = 0; i < count; i++) { for (j = 0; j < count; j++) { if (a[i] + b[j] == n) { if (a[i] * b[j] > num) { num = a[i] * b[j]; } } } } printf("%d", num); return 0; }
边栏推荐
- 微信小程序开发心得
- 错误:排序与角标越界
- [dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity
- Edit distance (multi-source BFS)
- 最短Hamilton路径 (状压DP)
- [algorithm] sword finger offer2 golang interview question 7: 3 numbers with 0 in the array
- 染色法判定二分图
- Agile development helps me
- [untitled]
- Chromatic judgement bipartite graph
猜你喜欢
Derivation of logistic regression theory
Mysql database reports an error: row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT=DY
Wechat applet development experience
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once
Office prompts that your license is not genuine pop-up box solution
What are the advantages of using SQL in Excel VBA
NovAtel 板卡OEM617D配置步骤记录
抗差估计在rtklib的pntpos函数(标准单点定位spp)中的c代码实现
Unity3d, Alibaba cloud server, platform configuration
Excel导入,导出功能实现
随机推荐
[算法] 剑指offer2 golang 面试题6:排序数组中的两个数字之和
染色法判定二分图
What are the functions and features of helm or terrain
Guided package method in idea
Fairygui joystick
[Chongqing Guangdong education] Shandong University College Physics reference materials
Liste des boucles de l'interface graphique de défaillance
Detailed explanation of balanced binary tree is easy to understand
[算法] 剑指offer2 golang 面试题1:整数除法
[algorithm] sword finger offer2 golang interview question 5: maximum product of word length
Lock wait timeout exceeded try restarting transaction
Idea problem record
【rtklib】在rtk下使用抗差自适应卡尔曼滤波初步实践
Excel导入,导出功能实现
Unity3D基础入门之粒子系统(属性介绍+火焰粒子系统案例制作)
The earth revolves around the sun
MySQL performance tuning - dirty page refresh
音乐播放(Toggle && PlayerPrefs)
Theoretical derivation of support vector machine
【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现