-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5dz.cpp
More file actions
50 lines (47 loc) · 921 Bytes
/
5dz.cpp
File metadata and controls
50 lines (47 loc) · 921 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
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <set>
#include <vector>
using namespace std;
bool FindVector(int start, vector<int>arr, int n)
{
for (int i = start + 1; i < arr.size(); ++i)
if (arr[i] == n)
return true;
return false;
}
bool DelimosTwo(vector<int> arr, int n)
{
for (int i = 0; i < arr.size(); ++i)
{
if (n % arr[i] == 0)
if (FindVector(0, arr, n / arr[i]))
return true;
}
return false;
}
int main()
{
vector<int> just;
int n;
cin >> n;
vector<int> arr;
for (int i = 0; i < n + 3; ++i)
arr.push_back(i);
for (int i = 2; i < n + 3; ++i)
{
if (arr[i] != 0)
{
just.push_back(arr[i]);
for (int j = i * i; j < n + 3; j += i)
arr[j] = 0;
}
}
for (int i = 0; i < just.size(); ++i)
{
if (FindVector(i, just, just[i] + 2))
cout << just[i] << endl;
else if (DelimosTwo(just, arr[i]))
cout << just[i] << endl;
}
return 0;
}