#include <bits/stdc++.h>
using namespace std;
#define sp << " " <<
#define int long long
#define vi vector<int>
#define pb push_back
const int N =1e6+1;
bool prime(int x) {
for (int i=2;i*i<=x;i++) if (x%i == 0) return 0;
return 1;
}
void solve() {
int a,b;
cin >> a >> b;
bool fl = (a>b);
if (fl) swap(a,b);
vi ans;
if (a == 2) {
if (prime(b-a)) {
ans.pb(a);
ans.pb(b);
}
else if (prime(b-a-2)) {
ans.pb(a);
ans.pb(b-2);
ans.pb(b);
}
else if (prime(b-a+2)) {
ans.pb(a);
ans.pb(b+2);
ans.pb(b);
}
else {
cout << -1 << endl;
return;
}
}
else {
if (a == 3 && b == 7) {
if(!fl)cout << 3 << endl << 3 sp 5 sp 7 << endl;
else cout << 3 << endl << 7 sp 5 sp 3 << endl;
return;
}
if (b-a >= 4) {
cout << -1 << endl;
return;
}
cout << 2 << endl;
if (!fl) cout << a sp b << endl;
else cout << b sp a << endl;
return;
}
cout << ans.size() << endl;
if (fl) reverse(ans.begin(),ans.end());
for (auto it : ans) cout << it << " ";
cout << endl;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |