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;
#define sp << " " <<
#define int long long
#define vi vector<int>
#define pb push_back
const int N =1e6+1;
bool prime(int x) {
for (int i=2;i*i<=x;i++) if (x%i == 0) return 0;
return 1;
}
void solve() {
int a,b;
cin >> a >> b;
bool fl = (a>b);
if (fl) swap(a,b);
vi ans;
if (a == 2) {
if (prime(b-a)) {
ans.pb(a);
ans.pb(b);
}
else if (prime(b-a-2)) {
ans.pb(a);
ans.pb(b-2);
ans.pb(b);
}
else if (prime(b-a+2)) {
ans.pb(a);
ans.pb(b+2);
ans.pb(b);
}
else {
cout << -1 << endl;
return;
}
}
else {
if (a == 3 && b == 7) {
cout << 3 << endl << 3 sp 5 sp 7 << endl;
return;
}
if (b-a >= 4) {
cout << -1 << endl;
return;
}
cout << 2 << endl;
if (!fl) cout << a sp b << endl;
else cout << b sp a << endl;
return;
}
cout << ans.size() << endl;
cout << fl << endl;
if (fl) reverse(ans.begin(),ans.end());
for (auto it : ans) cout << it << " ";
cout << endl;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
# | 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... |