0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 13:28:48 +00:00
OI-codes/Luogu/problem/P2640/P2640.cpp
2021-01-02 15:30:52 +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;
}