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 check(ll v) {
if (v <= 1) return false;
for (ll i = 2; i * i <= v; i++) {
if (v % i == 0) return false;
}
return true;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
ll a, b;
while (cin >> a >> b) {
if (a == 2) {
if (check(b - 2ll)) {
cout << "2\n";
cout << a << ' ' << b << '\n';
} else if(check(b + 2ll)){
cout << "3\n";
cout << a << ' ' << b + 2ll << ' ' << b << '\n';
} else {
cout << "-1\n";
}
} else if(b == 2) {
if (check(a - 2ll)) {
cout << "2\n";
cout << a << ' ' << b << '\n';
} else if(check(a + 2ll)){
cout << "3\n";
cout << a << ' ' << a + 2ll << ' ' << b << '\n';
} else {
cout << "-1\n";
}
} else {
if (abs(b - a) == 2) {
cout << "2\n";
cout << a << ' ' << b << '\n';
} else if(abs(b - a) == 4 && check(min(a, b) + 2)) {
ll p;
cout << "3\n";
if (a > b) p = b + 2;
else p = a + 2;
cout << a << ' ' << p << ' ' << b << '\n';
}else {
cout << "-1\n";
}
}
}
return 0;
}
# | 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... |