이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
ll A, B;
bool is_prime(ll x) {
if (x <= 1) return 0;
FOR (i, 2, sqrt(x)) if (x % i == 0) return 0;
return 1;
}
void solve() {
cin >> A >> B;
if (is_prime(abs(A - B))) {
cout << "2\n";
cout << A << ' ' << B << '\n';
return;
}
vector<ll> ans;
ans.pb(A);
if (A != 2) {
bool f = 0;
for (ll x : {A - 2, A, A + 2}) if (is_prime(x) && is_prime(abs(x - 2))) {
if (x != A) ans.pb(x);
f = 1;
break;
}
if (!f) {
cout << "-1\n";
return;
}
}
if (A != 2 && B != 2) ans.pb(2);
if (B != 2) {
bool f = 0;
for (ll x : {B - 2, B, B + 2}) if (is_prime(x) && is_prime(abs(x - 2))) {
if (x != B) ans.pb(x);
f = 1;
break;
}
if (!f) {
cout << "-1\n";
return;
}
}
ans.pb(B);
cout << ans.size() << '\n';
for (int x : ans) cout << x << ' ';
cout << '\n';
}
int main() {
Waimai;
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... |