You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
586 B

2 years ago
#include<bits/stdc++.h>
using namespace std;
//ŷ<><C5B7>ɸ
const int N = 10010;
int primes[N], cnt; // primes[]<5D><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool st[N]; // st[x]<5D>洢x<E6B4A2>Ƿ<EFBFBD><C7B7><EFBFBD>ɸ<EFBFBD><C9B8>
void get_primes(int n) {
for (int i = 2; i <= n; i++) {
if (!st[i]) primes[cnt++] = i;
for (int j = 0; primes[j] <= n / i; j++) {
st[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
}
int main() {
get_primes(200);
for (int i = 0; i < cnt; i++)
if (primes[i] > 100) cout << primes[i] << " ";
return 0;
}