#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 (a > b) swap(a, b);
if (check(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)) {
if (check((ll) abs(b + 2 - a))) {
cout << 3 << "\n";
cout << a << " " << b + 2 << " " << b;
return 0;
}
}
if (check(b - 2)) {
if (check((ll) abs(b - 2 - a))) {
cout << 3 << "\n";
cout << a << " " << b - 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 |
0 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 |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
80 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
95 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |