当前位置:网站首页>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; }
边栏推荐
- Unity scene jump and exit
- Fairygui character status Popup
- (the first set of course design) sub task 1-5 317 (100 points) (dijkstra: heavy edge self loop)
- It has been solved by personal practice: MySQL row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT
- The earth revolves around the sun
- Office提示您的许可证不是正版弹框解决
- Solution to the problem of automatic login in Yanshan University Campus Network
- MySQL performance tuning - dirty page refresh
- InnoDB dirty page refresh mechanism checkpoint in MySQL
- [算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
猜你喜欢
Force buckle 1189 Maximum number of "balloons"
Office prompts that your license is not genuine pop-up box solution
[算法] 剑指offer2 golang 面试题4:只出现一次的数字
染色法判定二分图
[GNSS data processing] Helmert variance component estimation analysis and code implementation
Novatel board oem617d configuration step record
记录:初次cmd启动MySQL拒接访问之解决
Role movement in the first person perspective
服务未正常关闭导致端口被占用
Unity scene jump and exit
随机推荐
[algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array
Detailed explanation of balanced binary tree is easy to understand
抗差估计在rtklib的pntpos函数(标准单点定位spp)中的c代码实现
Idea problem record
Unity scene jump and exit
Derivation of logistic regression theory
平衡二叉树详解 通俗易懂
C programming exercise
记录:Navicat Premium初次无法连接数据库MySQL之解决
Fairygui joystick
[Yu Yue education] guide business reference materials of Wuxi Vocational and Technical College of Commerce
[GNSS] robust estimation (robust estimation) principle and program implementation
堆排序【手写小根堆】
KF UD分解之伪代码实现进阶篇【2】
Naive Bayesian theory derivation
Unity3D基础入门之粒子系统(属性介绍+火焰粒子系统案例制作)
记录:newInstance()过时的代替方法
【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现
Devops' future: six trends in 2022 and beyond
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和