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 == 2ll) {
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(a - b) == 2) {
cout << "2\n";
cout << a << ' ' << b << '\n';
}else if(abs(a - b) == 4 && check(min(a, b) + 2ll)) {
ll p = (a > b) ? b + 2ll : a + 2ll;
cout << "3\n";
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... |