当前位置:网站首页>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; }
边栏推荐
- (core focus of software engineering review) Chapter V detailed design exercises
- Rt-ppp test using rtknavi
- Theoretical derivation of support vector machine
- [算法] 剑指offer2 golang 面试题2:二进制加法
- Affichage du changement de valeur du Buff de gain de l'interface graphique de défaillance
- (the first set of course design) sub task 1-5 317 (100 points) (dijkstra: heavy edge self loop)
- [algorithm] sword finger offer2 golang interview question 7: 3 numbers with 0 in the array
- 1041 be unique (20 points (s)) (hash: find the first number that occurs once)
- FGUI工程打包发布&导入Unity&将UI显示出来的方式
- Sharing ideas of on-chip transplantation based on rtklib source code
猜你喜欢
Basic DOS commands
Unity3D,阿里云服务器,平台配置
FairyGUI增益BUFF数值改变的显示
[algorithm] sword finger offer2 golang interview question 10: subarray with sum K
FairyGUI簡單背包的制作
堆排序【手写小根堆】
Theoretical derivation of support vector machine
记录:初次cmd启动MySQL拒接访问之解决
Mixed use of fairygui button dynamics
[algorithm] sword finger offer2 golang interview question 1: integer division
随机推荐
wsl常用命令
[algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K
Lean product development - Lean Software Development & lean product development
微信小程序开发心得
IText 7 generate PDF summary
记录:下一不小心写了个递归
FairyGUI复选框与进度条的组合使用
3月15号 Go 1.18 正式版发布 了解最新特色以及使用方法
Knowledge system of digital IT practitioners | software development methods -- agile
Design and implementation of general interface open platform - (39) simple and crude implementation of API services
【无标题】
Devops' future: six trends in 2022 and beyond
Unity3d, Alibaba cloud server, platform configuration
[算法] 剑指offer2 golang 面试题6:排序数组中的两个数字之和
[Yu Yue education] guide business reference materials of Wuxi Vocational and Technical College of Commerce
Unity scene jump and exit
FairyGUI摇杆
Fairygui loop list
平衡二叉树详解 通俗易懂
FGUI工程打包发布&导入Unity&将UI显示出来的方式