0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 19:16:27 +00:00
OI-codes/Luogu/P2640/P2640.cpp

38 lines
650 B
C++
Raw Normal View History

2020-11-03 11:12:08 +00:00
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x) {
if (x == 1) {
return false;
}
if (x == 2) {
return true;
}
if (x % 2 == 0) {
return false;
}
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) {
return false;
}
}
return true;
}
int main() {
2021-11-19 09:01:13 +00:00
int n, k;
2020-11-03 11:12:08 +00:00
bool flag = false;
cin >> n >> k;
for (int i = 2; i + k <= n; i++) {
if (isPrime(i) && isPrime(i + k)) {
cout << i << ' ' << i + k << endl;
flag = true;
}
}
if (!flag) {
cout << "empty" << endl;
}
return 0;
}