'commit'
This commit is contained in:
30
TangDou/LuoGuBook/P1304_1.cpp
Normal file
30
TangDou/LuoGuBook/P1304_1.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
//欧拉筛
|
||||
const int N = 1e5 + 10;
|
||||
int primes[N], cnt; // primes[]存储所有素数
|
||||
bool st[N]; // st[x]存储x是否被筛掉
|
||||
void get_primes(int n) {
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (!st[i]) primes[cnt++] = i;
|
||||
for (int j = 0; primes[j] * i <= n; j++) {
|
||||
st[primes[j] * i] = true;
|
||||
if (i % primes[j] == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int n;
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
get_primes(n);
|
||||
for (int i = 4; i <= n; i += 2)
|
||||
for (int j = 2; j < i; j++)
|
||||
if (!st[j] && !st[i - j]) {
|
||||
printf("%d=%d+%d\n", i, j, i - j);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user