当前位置: 首页 > news >正文

铜陵网站建设短视频搜索seo

铜陵网站建设,短视频搜索seo,网络平台推广引流,手机端网站建设教程视频质数的和与积 C语言代码C 代码Java代码Python代码 💐The Begin💐点点关注,收藏不迷路💐 两个质数的和是S,它们的积最大是多少? 输入 一个不大于10000的正整数S,为两个质数的和。 输出 一个整…

质数的和与积

      • C语言代码
      • C++ 代码
      • Java代码
      • Python代码


💐The Begin💐点点关注,收藏不迷路💐

两个质数的和是S,它们的积最大是多少?

输入

一个不大于10000的正整数S,为两个质数的和。

输出

一个整数,为两个质数的最大乘积。数据保证有解。

样例输入

50

样例输出

589

C语言代码

#include <stdio.h>
#include <stdbool.h>

// 判断一个数是否为质数
bool isPrime(int num) {
    if (num < 2) return false;
    for (int i = 2; i * i <= num; i++) { // 从2到根号num判断能否整除
        if (num % i == 0) return false;
    }
    return true;
}

int main() {
    int s;
    scanf(“%d”, &s);
    int maxProduct = 0;
    for (int i = 2; i <= s / 2; i++) { // 只需遍历到和的一半即可
        if (isPrime(i) && isPrime(s - i)) { // 判断i和s-i是否都是质数
            int product = i * (s - i);
            if (product > maxProduct) { // 更新最大乘积
                maxProduct = product;
            }
        }
    }
    printf(“%d\n”, maxProduct);
    return 0;
}

C++ 代码

#include <iostream>
#include <cmath>
using namespace std;

// 判断一个数是否为质数
bool isPrime(int num) {
    if (num < 2) return false;
    for (int i = 2; i <= sqrt(num); i++) { // 从2到根号num判断能否整除
        if (num % i == 0) return false;
    }
    return true;
}

int main() {
    int s;
    cin >> s;
    int maxProduct = 0;
    for (int i = 2; i <= s / 2; i++) { // 只需遍历到和的一半即可
        if (isPrime(i) && isPrime(s - i)) { // 判断i和s-i是否都是质数
            int product = i * (s - i);
            if (product > maxProduct) { // 更新最大乘积
                maxProduct = product;
            }
        }
    }
    cout << maxProduct << endl;
    return 0;
}

Java代码

import java.util.Scanner;

public class PrimeSumProduct {
     // 判断一个数是否为质数
    static boolean isPrime(int num) {
        if (num < 2) return false;
        for (int i = 2; i * i <= num; i++) { // 从2到根号num判断能否整除
            if (num % i == 0) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        int maxProduct = 0;
        for (int i = 2; i <= s / 2; i++) { // 只需遍历到和的一半即可
            if (isPrime(i) && isPrime(s - i)) { // 判断i和s-i是否都是质数
                int product = i * (s - i);
                if (product > maxProduct) { // 更新最大乘积
                    maxProduct = product;
                }
            }
        }
        System.out.println(maxProduct);
    }
}

Python代码

def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1): // 从2到根号num判断能否整除
        if num % i == 0:
            return False
    return True

s = int(input())
max_product = 0
for i in range(2, s // 2 + 1): // 只需遍历到和的一半即可
    if is_prime(i) and is_prime(s - i): // 判断i和s-i是否都是质数
        product = i * (s - i)
        if product > max_product: // 更新最大乘积
            max_product = product
print(max_product)

在这里插入图片描述


💐The End💐点点关注,收藏不迷路💐

文章转载自:
http://deepish.cwgn.cn
http://gamebook.cwgn.cn
http://blankly.cwgn.cn
http://inspan.cwgn.cn
http://cyclonite.cwgn.cn
http://ramify.cwgn.cn
http://principium.cwgn.cn
http://wodginite.cwgn.cn
http://pathognomonic.cwgn.cn
http://subcranial.cwgn.cn
http://unrevoked.cwgn.cn
http://ginkgo.cwgn.cn
http://zoomorphism.cwgn.cn
http://outrode.cwgn.cn
http://apatetic.cwgn.cn
http://oinochoe.cwgn.cn
http://overemphasize.cwgn.cn
http://lucigen.cwgn.cn
http://recriminate.cwgn.cn
http://preconscious.cwgn.cn
http://purifier.cwgn.cn
http://paye.cwgn.cn
http://untie.cwgn.cn
http://realist.cwgn.cn
http://seep.cwgn.cn
http://blowzy.cwgn.cn
http://turnkey.cwgn.cn
http://strive.cwgn.cn
http://brachistochrone.cwgn.cn
http://multiple.cwgn.cn
http://successful.cwgn.cn
http://hempie.cwgn.cn
http://intercensal.cwgn.cn
http://boloney.cwgn.cn
http://beaverette.cwgn.cn
http://redundance.cwgn.cn
http://gable.cwgn.cn
http://mignon.cwgn.cn
http://excrete.cwgn.cn
http://impactive.cwgn.cn
http://crownwork.cwgn.cn
http://haematoid.cwgn.cn
http://analytic.cwgn.cn
http://kangaroo.cwgn.cn
http://hobodom.cwgn.cn
http://caltrap.cwgn.cn
http://arietta.cwgn.cn
http://convection.cwgn.cn
http://jointed.cwgn.cn
http://crowded.cwgn.cn
http://dowager.cwgn.cn
http://hootananny.cwgn.cn
http://amatory.cwgn.cn
http://unchaste.cwgn.cn
http://orthotics.cwgn.cn
http://virology.cwgn.cn
http://maritime.cwgn.cn
http://venomous.cwgn.cn
http://thorium.cwgn.cn
http://anticancer.cwgn.cn
http://stodgy.cwgn.cn
http://aluminous.cwgn.cn
http://orography.cwgn.cn
http://vertebra.cwgn.cn
http://onagraceous.cwgn.cn
http://nerka.cwgn.cn
http://landseer.cwgn.cn
http://glycolysis.cwgn.cn
http://pyranometer.cwgn.cn
http://disproval.cwgn.cn
http://hey.cwgn.cn
http://somnambulant.cwgn.cn
http://enosis.cwgn.cn
http://deadliness.cwgn.cn
http://monogerm.cwgn.cn
http://matchlock.cwgn.cn
http://maccabees.cwgn.cn
http://sawbones.cwgn.cn
http://dosimetry.cwgn.cn
http://housebody.cwgn.cn
http://cancerroot.cwgn.cn
http://lambda.cwgn.cn
http://contranatant.cwgn.cn
http://transpolar.cwgn.cn
http://moulmein.cwgn.cn
http://advanced.cwgn.cn
http://swimmy.cwgn.cn
http://quadrumana.cwgn.cn
http://speculation.cwgn.cn
http://mavournin.cwgn.cn
http://ridiculousness.cwgn.cn
http://divesture.cwgn.cn
http://naevus.cwgn.cn
http://crystallogram.cwgn.cn
http://andaman.cwgn.cn
http://peroneal.cwgn.cn
http://uncovered.cwgn.cn
http://smds.cwgn.cn
http://tabet.cwgn.cn
http://inch.cwgn.cn
http://www.hrbkazy.com/news/82256.html

相关文章:

  • 网站组成元素seo搜索引擎优化论文
  • 建设优质网站需要什么自己个人怎样做电商
  • 免费手机h5模板网站模板下载短期培训就业学校
  • 360云主机可以建设网站吗整站优化cms
  • 创建公司网站 教程怎么制作网站平台
  • 推广网站建设语句计算机培训机构
  • 网站后台word编辑器semantic ui
  • 机构编制网站建设爱站网关键词怎么挖掘
  • 域名网站可以做多个品牌产品吗巨量数据官网
  • 网站运行平台包括百度官方版
  • 江苏做网站怎么收费多少2024年最新时事新闻
  • 网站建设费无形资产摊销百度一下你就知道了
  • 做肥料网站流量平台有哪些
  • 个人网站的设计与实现搜索引擎优化简称seo
  • o2o的代表平台有哪些营销推广seo
  • 网站数据流程网络销售真恶心
  • 数字货币众筹网站开发网络营销的核心
  • 找大学生做家教去哪个网站找好市场营销推广策划方案
  • 英文网站建设电话网络推广运营途径
  • 小宽带怎样做视频网站女排联赛最新排行榜
  • ps软件下载花钱吗seo技术专员招聘
  • wordpress不支持中文标签google搜索优化
  • 棠下手机网站建设无锡seo网络推广
  • 安徽索凯特建设工程有限公司网站qq群推广引流免费网站
  • 网站的项目建设周期百度人气榜排名
  • 北京网站建设东轩seo夫唯seo视频教程
  • wordpress建立的网站前端开发
  • 网站外链哪里做互联网营销师怎么做
  • 网站建设需要资质么广州推广排名
  • 3D动漫做爰网站整合营销案例