#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool check(ll v) {
if (v <= 1) return false;
for (ll i = 2; i * i <= v; i++) {
if (v % i == 0) return false;
}
return true;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
ll a, b;
while (cin >> a >> b) {
if (a == 2ll) {
if (check(b - 2ll)) {
cout << "2\n";
cout << a << ' ' << b << '\n';
} else if(check(b + 2ll)){
cout << "3\n";
cout << a << ' ' << b + 2ll << ' ' << b << '\n';
} else {
cout << "-1\n";
}
} else if(b == 2) {
if (check(a - 2ll)) {
cout << "2\n";
cout << a << ' ' << b << '\n';
} else if(check(a + 2ll)){
cout << "3\n";
cout << a << ' ' << a + 2ll << ' ' << b << '\n';
} else {
cout << "-1\n";
}
} else {
if (abs(a - b) == 2) {
cout << "2\n";
cout << a << ' ' << b << '\n';
}else if(abs(a - b) == 4 && check(min(a, b) + 2ll)) {
ll p = (a > b) ? b + 2ll : a + 2ll;
cout << "3\n";
cout << a << ' ' << p << ' ' << b << '\n';
}else {
cout << "-1\n";
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |