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>
#define all(x) x.begin(),x.end()
#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define pii pair<int, int>
#define sz(x) ((int)x.size())
using namespace std;
const int N = 10010;
const int oo = 2e9;
typedef long long ll;
vector<ll> vc;
bool t1, t2;
ll a, b;
void BAD() { cout << -1; exit(0); }
bool prim(ll x){
if (x == 1) return 0;
for (ll i = 2; i * i <= x; i++)
if (x % i == 0)
return 0;
return 1;
}
void ANS(){
cout << sz(vc) << '\n';
for (ll x : vc)
cout << x << " ";
exit(0);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
cin >> a >> b;
if (prim(abs(a - b))){
cout << "2\n" << a << " " << b;
return 0;
}
if (a == 2){
if (prim(b - 2))
t2 = 0;
else if (prim(b + 2))
t2 = 1;
else BAD();
vc.PB(2);
if (t2)
vc.PB(b + 2);
vc.PB(b);
ANS();
return 0;
}
if (b == 2){
if (prim(a - 2))
t2 = 0;
else if (prim(a + 2))
t2 = 1;
else BAD();
vc.PB(a);
if (t2)
vc.PB(a + 2);
vc.PB(2);
ANS();
return 0;
}
if (prim(a - 2))
t1 = 0;
else if (prim(a + 2))
t1 = 1;
else BAD();
if (prim(b - 2))
t2 = 0;
else if (prim(b + 2))
t2 = 1;
else BAD();
vc.clear();
if (t1){
vc.PB(a);
vc.PB(a + 2);
} else vc.PB(a);
vc.PB(2);
if (t2){
vc.PB(b + 2);
}
vc.PB(b);
ANS();
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... |