#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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
409 ms |
296 KB |
Integer parameter [name=arr[4]] equals to -2039078211, violates the range [1, 1000000000000000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
412 ms |
312 KB |
Integer parameter [name=arr[1]] equals to -2145466189, violates the range [1, 1000000000000000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
447 ms |
296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
329 ms |
212 KB |
Integer parameter [name=arr[4]] equals to -2070243847, violates the range [1, 1000000000000000] |
2 |
Halted |
0 ms |
0 KB |
- |