This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool isPrime(ll n) {
if (n < 2) return false;
for(ll i = 2; i*i <= n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll A, B;
cin >> A >> B;
bool ok = 0;
if (abs(A - B) == 2) {
cout << 2 << "\n"
<< A << " " << B;
ok = 1;
} else {
if (isPrime(B - 2) && isPrime(abs(A - (B - 2)))) {
cout << 3 << "\n"
<< A << " " << B - 2 << " " << B << "\n";
ok = 1;
} else if (isPrime(B + 2) && isPrime(abs(A - (B + 2)))) {
cout << 3 << "\n"
<< A << " " << B + 2 << " " << B << "\n";
ok = 1;
}
}
if (!ok) {
cout << -1;
}
return 0;
}
//~ check for overflows
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |