当前位置:网站首页>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; }
边栏推荐
- RTKLIB: demo5 b34f. 1 vs b33
- 341. Flatten nested list iterator
- Database table splitting strategy
- [算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
- Basic DOS commands
- Database course design: college educational administration management system (including code)
- MySQL performance tuning - dirty page refresh
- Unity3D,阿里云服务器,平台配置
- 异常:IOException:Stream Closed
- [算法] 剑指offer2 golang 面试题8:和大于或等于k的最短子数组
猜你喜欢

In 2020, the average salary of IT industry exceeded 170000, ranking first

【干货】提升RTK模糊度固定率的建议之周跳探测

Fairygui character status Popup

Basic DOS commands

Unity3d, Alibaba cloud server, platform configuration

Mixed use of fairygui button dynamics

Problems and solutions of robust estimation in rtklib single point location spp

Mysql database reports an error: row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT=DY
![[algorithm] sword finger offer2 golang interview question 2: binary addition](/img/c2/6f6c3bd4d70252ba73addad6a3a9c1.png)
[algorithm] sword finger offer2 golang interview question 2: binary addition
![[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和](/img/17/e7c9bfa867030af97eb66a7932c7e3.png)
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和
随机推荐
Fairygui loop list
Implementation of Excel import and export functions
[dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity
[算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
Fundamentals of UD decomposition of KF UD decomposition [1]
rtklib单点定位spp使用抗差估计遇到的问题及解决
[algorithm] sword finger offer2 golang interview question 10: subarray with sum K
C code implementation of robust estimation in rtklib's pntpos function (standard single point positioning spp)
Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
(the first set of course design) sub task 1-5 317 (100 points) (dijkstra: heavy edge self loop)
Easy to use shortcut keys in idea
PRIDE-PPPAR源码解析
错误: 找不到符号
MySQL error warning: a long semaphore wait
[算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等
Mysql database index
RTKLIB: demo5 b34f.1 vs b33
[algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
NovAtel 板卡OEM617D配置步骤记录
Rt-ppp test using rtknavi