'commit'
This commit is contained in:
24
LuoGu/RuMen/P1304.cpp
Normal file
24
LuoGu/RuMen/P1304.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include<bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool isPrime(int number) {
|
||||
for (int i = 2; i * i <= number; i++)
|
||||
if (number % i == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;//输入的数
|
||||
cin >> n;
|
||||
//计算从4开始到这个指定数字结束
|
||||
for (int i = 4; i <= n; i += 2) {
|
||||
for (int j = 2; j < i; j++) {
|
||||
if (isPrime(j) && isPrime(i - j)) {
|
||||
cout << i << "=" << j << "+" << i - j << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user