Update CMakeLists.txt
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int primes[2001];
|
||||
|
||||
bool is_prime(int a) {
|
||||
for (int i = 2; i * i <= a; i++) {
|
||||
if (a % i != 0) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void init_primes() {
|
||||
int current_num = 2, i = 0;
|
||||
for (;; current_num++) {
|
||||
if (is_prime(current_num)) {
|
||||
primes[i] = current_num;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
int a;
|
||||
cin >> a;
|
||||
if (a % 2 != 0 || a < 6) {
|
||||
cout << "Error!" << endl;
|
||||
} else
|
||||
for (int i = 0; primes[i] <= a / 2; i++) {
|
||||
if (is_prime(a - primes[i])) {
|
||||
cout << a << "=" << i << "+" << a - i << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// x[0]..x[99]
|
||||
|
||||
bool is_prime(int n) {
|
||||
for (int i=2; i*i<=n; i++) {
|
||||
if (n%i == 0) {return false;}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cout << is_prime(4);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user