当前位置:网站首页>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; }
边栏推荐
- 堆排序【手写小根堆】
- 记录:下一不小心写了个递归
- Fundamentals of UD decomposition of KF UD decomposition [1]
- [算法] 剑指offer2 golang 面试题9:乘积小于k的子数组
- GPS高程拟合抗差中误差的求取代码实现
- Problems and solutions of robust estimation in rtklib single point location spp
- RTKLIB: demo5 b34f.1 vs b33
- [algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
- [算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等
- Meanings and differences of PV, UV, IP, VV, CV
猜你喜欢

Teach you to release a DeNO module hand in hand

FairyGUI按钮动效的混用

Particle system for introduction to unity3d Foundation (attribute introduction + case production of flame particle system)

Combination of fairygui check box and progress bar
![[untitled]](/img/b1/9a2bebebb24132a405fc4e7d854e51.png)
[untitled]

C code implementation of robust estimation in rtklib's pntpos function (standard single point positioning spp)

Novatel board oem617d configuration step record

Guided package method in idea

Force buckle 1189 Maximum number of "balloons"

Mixed use of fairygui button dynamics
随机推荐
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
Introduction to the daily practice column of the Blue Bridge Cup
FairyGUI简单背包的制作
Detailed explanation of balanced binary tree is easy to understand
Solution to the problem of automatic login in Yanshan University Campus Network
Fabrication of fairygui simple Backpack
How to reduce the shutdown time of InnoDB database?
Compile GDAL source code with nmake (win10, vs2022)
Lean product development - Lean Software Development & lean product development
基本Dos命令
基于rtklib源码进行片上移植的思路分享
【无标题】
Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
On March 15, the official version of go 1.18 was released to learn about the latest features and usage
堆排序【手写小根堆】
Unity scene jump and exit
Meanings and differences of PV, UV, IP, VV, CV
Novatel board oem617d configuration step record
Matlab读取GNSS 观测值o文件代码示例
Game 280 weekly