# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198100 | ZwariowanyMarcin | Lutrija (COCI19_lutrija) | C++14 | 238 ms | 476 KiB |
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 fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define ld double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);
using namespace std;
LL x, y;
int z;
vector <LL> ans;
bool prime(LL n) {
if (n <= 1) return 0;
for (int i = 2; (LL) i * i <= n; ++i)
if (n % i == 0) return 0;
return 1;
}
int main() {
scanf ("%lld %lld", &x, &y);
if (x > y) {
z = 1;
swap(x, y);
}
if ((x & 1) && (y & 1)) {
bool ok = 1;
for (int i = x; i <= y; i += 2) {
ans.pb(i);
if (!prime(i) || ss(ans) > 30) {
ok = 0;
break;
}
}
if (ok) {
printf ("%d\n", ss(ans));
if (z) reverse(ans.begin(), ans.end());
for (auto it : ans)
printf ("%lld ", it);
exit(0);
}
ans.clear();
}
bool ok1 = 0;
bool ok2 = 0;
ans.pb(x);
if (x == 2) ok1 = 1;
if (!ok1) {
if (prime(x - 2)) {
ok1 = 1;
ans.pb(2);
}
if (!ok1) {
if (prime(x + 2)) {
ok1 = 1;
ans.pb(x + 2);
ans.pb(2);
}
}
}
if (prime(y - 2)) {
ok2 = 1;
ans.pb(y);
}
if (!ok2 && prime(y + 2)) {
ok2 = 1;
ans.pb(y + 2);
ans.pb(y);
}
if (ok1 && ok2) {
if (z) reverse(ans.begin(), ans.end());
printf ("%d\n", ss(ans));
for (auto it : ans)
printf ("%lld ", it);
exit(0);
}
printf ("-1\n");
return 0;
}
Compilation message (stderr)
# | 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... |