#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
ll a, b;
bool check(ll x) {
if (x == 1) return false;
if (x == 2 || x == 3) return true;
for (ll i = 2; i <= sqrt(x); ++ i) {
if (x % i == 0) return false;
}
return true;
}
int main() {
//freopen(".INP", "r", stdin);
//freopen(".OUT", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> a >> b;
if (check(abs(b - a))) {
cout << 2 << "\n";
cout << a << " " << b;
return 0;
}
if (a == 2 && b == 5) {
cout << 2 << "\n";
cout << 2 << " " << 5;
return 0;
}
if (a == 2 && b == 7) {
cout << 3 << "\n";
cout << 2 << " " << 5 << " " << 7;
return 0;
}
if (check(b + 2) && (b + 2) != a) {
if (check((ll) abs(b + 2 - a))) {
cout << 3 << "\n";
cout << a << " " << b + 2 << " " << b;
return 0;
}
}
if (check(b - 2) && (b - 2) != a) {
if (check((ll) abs(b - 2 - a))) {
cout << 3 << "\n";
cout << a << " " << b - 2 << " " << b;
return 0;
}
}
if (check(a + 2) && (a + 2) != b) {
if (check((ll) abs(a + 2 - b))) {
cout << 3 << "\n";
cout << a << " " << a + 2 << " " << b;
return 0;
}
}
if (check(a - 2) && (a - 2) != b) {
if (check((ll) abs(a - 2 - b))) {
cout << 3 << "\n";
cout << a << " " << a - 2 << " " << b;
return 0;
}
}
cout << -1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
158 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
154 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
180 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |