#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){
if(x<=1)return 0;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 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 |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
256 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
164 ms |
356 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
181 ms |
376 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
133 ms |
504 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |