#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mid (l+r)/2
#define left 2*i+1
#define righ 2*i+2
using namespace std;
ll a,b;
bool check(ll x){
for(ll i=2;i*i<=x;i++){
if(x%i)continue;
return 0;
}
return 1;
}
int main()
{
cin>>a>>b;
if(abs(a-b)==2){
cout<<2<<endl;
cout<<a<<' '<<b<<endl;
return 0;
}
if(a==2){
if(check(b-2)){
cout<<2<<endl;
cout<<a<<' '<<b<<endl;
return 0;
}
if(check(b+2)){
cout<<3<<endl;
cout<<a<<' '<<b+2<<' '<<b<<endl;
return 0;
}
}
if(b==2){
if(check(a-2)){
cout<<2<<endl;
cout<<a<<' '<<b<<endl;
return 0;
}
if(check(a+2)){
cout<<3<<endl;
cout<<a<<' '<<a+2<<' '<<b<<endl;
return 0;
}
}
if(check(a-2)){
if(check(b-2)){
cout<<3<<endl;
cout<<a<<' '<<2<<' '<<b<<endl;
return 0;
}
if(check(b+2)){
cout<<4<<endl;
cout<<a<<' '<<2<<' '<<b+2<<' '<<b<<endl;
return 0;
}
}
if(check(a+2)){
if(check(b-2)){
cout<<4<<endl;
cout<<a<<' '<<a+2<<' '<<2<<' '<<b<<endl;
}
if(check(b+2)){
cout<<5<<endl;
cout<<a<<' '<<a+2<<' '<<2<<' '<<b+2<<' '<<b<<endl;
}
}
cout<<-1<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
167 ms |
376 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
164 ms |
376 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
376 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
135 ms |
360 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |