This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |