-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3165.cpp
More file actions
32 lines (26 loc) · 687 Bytes
/
3165.cpp
File metadata and controls
32 lines (26 loc) · 687 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
#include <iostream>
#include <vector>
using namespace std;
int main(){
int entrada;
vector<int> numeros_primos;
cin >> entrada;
for(int i=2; i<=entrada; i++){
bool divide = false;
for(int j=2; j<=i; j++){
int resto = i % j;
if(i != j && resto == 0){
divide = true;
break;
}
}
if(divide == false) numeros_primos.push_back(i);
}
for(int e=numeros_primos.size(); e>0; e--) {
if(numeros_primos[e] - numeros_primos[e-1] == 2){
cout << numeros_primos[e-1] << " " << numeros_primos[e] << endl;
break;
}
}
return 0;
}