-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathab.cpp
More file actions
40 lines (30 loc) · 675 Bytes
/
ab.cpp
File metadata and controls
40 lines (30 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
// #define int long long
#ifdef fread_unlocked
#define fread fread_unlocked
#endif
#define PII pair<int, int>
using namespace std;
signed main() {
#ifdef LOCAL
freopen("sample.in","r",stdin);
#endif
int max = 5;
bool composite[max + 1];
vector<int> primes;
for (int i = 0; i < max + 1; i++) {
composite[i] = false;
}
for (int i = 2; i <= max; i++) {
if (!composite[i]) {
primes.emplace_back(i);
for (int j = i; j <= max; j += i) {
composite[j] = true;
}
}
}
for (const auto &prime : primes) {
printf("%d\n", prime);
}
return 0;
}