当前位置:网站首页>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; }
边栏推荐
- [算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
- [Chongqing Guangdong education] Shandong University College Physics reference materials
- 记录:初次cmd启动MySQL拒接访问之解决
- Basic DOS commands
- WSL common commands
- Special palindromes of daily practice of Blue Bridge Cup
- 【无标题】
- [dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity
- How to reduce the shutdown time of InnoDB database?
- Code example of MATLAB reading GNSS observation value o file
猜你喜欢
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once
The port is occupied because the service is not shut down normally
Office提示您的许可证不是正版弹框解决
《软件测试》习题答案:第一章
Excel导入,导出功能实现
[algorithm] sword finger offer2 golang interview question 12: the sum of the left and right sub arrays is equal
[algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
Derivation of logistic regression theory
Detailed explanation of balanced binary tree is easy to understand
Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)
随机推荐
使用rtknavi进行RT-PPP测试
Liste des boucles de l'interface graphique de défaillance
[算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
Realization of the code for calculating the mean square error of GPS Height Fitting
MySQL error warning: a long semaphore wait
Matlab读取GNSS 观测值o文件代码示例
染色法判定二分图
[算法] 剑指offer2 golang 面试题1:整数除法
Unity3D基础入门之粒子系统(属性介绍+火焰粒子系统案例制作)
记录:初次cmd启动MySQL拒接访问之解决
Lean product development - Lean Software Development & lean product development
Solution to the problem of automatic login in Yanshan University Campus Network
GNSS定位精度指标计算
【GNSS】抗差估计(稳健估计)原理及程序实现
【RTKLIB 2.4.3 b34 】版本更新简介一
FairyGUI人物状态弹窗
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
FairyGUI按钮动效的混用
Pride-pppar source code analysis
[algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K