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>
using namespace std;
long long a,b,am2,ap2,bm2,bp2;
bool pr(long long n){
for(long long i=2;i*i<=n;i++){
if(!(n%i)) return 0;
// cout<<"ok";
}
return 1;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>a>>b;
if(pr(a-2)){
am2=1;
}
if(pr(a+2)){
ap2=1;
}
if(!am2 and !ap2){
cout<<-1;
return 0;
}
if(pr(b-2)){
bm2=1;
}
if(pr(b+2)){
bp2=1;
}
if(!am2 and !ap2){
cout<<-1;
return 0;
}
if(a==2){
if(bm2){
cout<<2<<endl<<2<<" "<<b;
}
else{
cout<<3<<endl<<2<<" "<<b+2<<" "<<b;
}
}
else if(b==2){
if(bm2){
cout<<2<<endl<<a<<" "<<2;
}
else{
cout<<3<<endl<<a<<" "<<a+2<<" "<<2;
}
}
else if(ap2 and bp2){
cout<<5<<endl<<a<<" "<<a+2<<" "<<2<<" "<<b+2<<" "<<b;
}
else if(am2 and bp2){
cout<<4<<endl<<a<<" "<<2<<" "<<b+2<<" "<<b;
}
else if(ap2 and bm2){
cout<<4<<endl<<a<<" "<<a+2<<" "<<2<<" "<<b;
}
else if(am2 and bm2){
cout<<3<<endl<<a<<" "<<2<<" "<<b;
}
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... |