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;
bool check(long long x){
if(x<2)return 0;
long long s=sqrt(x);
for(long long i=2;i<=s;i++){
if(x%i==0)return 0;
}
return 1;
}
int main(){
long long a,b;cin>>a>>b;
if(check(abs(b-a)))cout<<2<<"\n"<<a<<" "<<b;
else if(a==2&&check(b+2))cout<<3<<"\n"<<a<<" "<<b+2<<" "<<b;
else if(b==2&&check(a+2))cout<<3<<"\n"<<a<<" "<<a+2<<" "<<b;
else if(check(a+2)&&check(b-2))cout<<4<<"\n"<<a<<" "<<a+2<<" "<<2<<" "<<b;
else if(check(a-2)&&check(b+2))cout<<4<<"\n"<<a<<" "<<2<<" "<<b+2<<" "<<b;
else if(check(a-2)&&check(b-2))cout<<3<<"\n"<<a<<" "<<2<<" "<<b;
else if(check(a+2)&&check(b+2))cout<<5<<"\n"<<a<<" "<<a+2<<" "<<2<<" "<<b+2<<" "<<b;
else cout<<-1;
}
# | 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... |