0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 05:18:48 +00:00
OI-codes/problem/P2640/P2640.cpp
2020-11-03 19:12:08 +08:00

38 lines
651 B
C++

#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() {
int n, k;
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;
}