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(int i){
bool prime= 1 ;
for(int j=2;j*j<=i;j++){
if(i%j==0){
prime = 0;
}
}
return prime ;
}
int main(){
int a , b ;
cin>>a>>b ;
vector<int> p ;
vector<int> isp(1001) ;
for(int i=2;i<=1000;i++){
bool prime= check(i) ;
isp[i] = prime ;
if(prime) p.push_back(i) ;
}
if(isp[abs(a-b)]){
cout << 2 << endl ;
cout << a << " " << b ;
return 0 ;
}
for(int i=1;i<1001;i++){
if(isp[i]==0) continue ;
int x = i ;
int dif = abs(x-a) , diff = abs(x-b) ;
if(isp[dif]&&isp[diff]){
cout << 3 << endl ;
cout << a << " "<< x << " "<< b ;
return 0 ;
}
}
cout << -1 ;
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... |