0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 13:18:46 +00:00
Baoshuo Ren 2022-06-10 16:48:16 +08:00
parent a30aba29cc
commit 49673d472b
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
5 changed files with 54 additions and 0 deletions

42
AcWing/4268/4268.cpp Normal file
View File

@ -0,0 +1,42 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
bool isPrime(int x) {
if (x <= 1) return false;
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) {
return false;
}
}
return true;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int x;
cin >> x;
if (isPrime(x) && isPrime(x - 6)) {
cout << "Yes" << endl
<< x - 6 << endl;
} else if (isPrime(x) && isPrime(x + 6)) {
cout << "Yes" << endl
<< x + 6 << endl;
} else {
cout << "No" << endl;
while (!(isPrime(x) && (isPrime(x - 6) || isPrime(x + 6)))) x++;
cout << x << endl;
}
return 0;
}

BIN
AcWing/4268/data/11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AcWing/4268/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AcWing/4268/data/12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AcWing/4268/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.