This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// iee
#include <bits/stdc++.h>
#define rep(i, a, b) for (auto i = (a); i <= (b); ++i)
#define per(i, a, b) for (auto i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);
template <class T> void read(T &x) {
x = 0; int f = 1, ch = getchar();
while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar();
x *= f;
}
int main() {
int TT = 1; // cin >> TT;
rep(CAS, 1, TT)
work(CAS);
return 0;
}
bool isp(ll x) {
if (x <= 1) return 0;
rep(i, 2, x / i) if (x % i == 0) return 0;
return 1;
}
void work(int CASE) {
ll a, b; cin >> a >> b;
if (a != 2 && !isp(a - 2) && !isp(a + 2)) { puts("-1"); return; }
if (b != 2 && !isp(b - 2) && !isp(b + 2)) { puts("-1"); return; }
vector<int> ans;
if (isp(a - 2)) ans.push_back(a);
else if (isp(a + 2)) ans.push_back(a), ans.push_back(a + 2);
ans.push_back(2);
if (isp(b - 2)) ans.push_back(b);
else if (isp(b + 2)) ans.push_back(b + 2), ans.push_back(b);
cout << ans.size() << '\n';
for (int x: ans) cout << x << ' ';
}
# | 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... |