CJ/Project1/6.01.09.质数的和与积【小学奥数7827】.cpp

42 lines
705 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

////9质数的和与积【小学奥数7827】
////两个质数的和是S它们的积最大是多少
////输入 :
////一个不大于10000的正整数S为两个质数的和。
////输出 :
////一个整数,为两个质数的最大乘积。数据保证有解。
////样例输入 :
////50
////样例输出 :
//// 589
////枚举法
//// 2->48
//// 3->47
//// 25->2
//#include<iostream>
//
//bool isPrime(int n){
// for(int i = 2; i <= n / 2; i++){
// if(n % i == 0)
// return false;
// }
// return true;
//}
//
//using namespace std;
//int main(){
// int n;
// cin >> n;
// for (int i = n/2; i>=2; i--)
// {
// int j = n - i;
// if (isPrime(i) && isPrime(j))
// {
// cout << i << " " << j << endl;
// cout<< i * j << endl;
// return 0;
// }
// }
//
// return 0;
//}