0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 21:28:48 +00:00
OI-codes/Luogu/problem/P2640/P2640.cpp

38 lines
651 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() {
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;
}