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 IsPrime(long long n){
if(n == 1)return 0;
if(n == 2)return 1;
if(n % 2 == 0)return 0;
for(long long i = 3;i * i <= n;i += 2){
if(n % i == 0)return 0;
}
return 1;
}
int main()
{
long long a, b;
cin >> a >> b;
if(IsPrime(abs(a - b))){
cout << "2 \n" << a << " " << b;
return 0;
}
else{
for(int i = 2;i <= 1000;++i){
if(IsPrime(i) && IsPrime(abs(a - i)) && IsPrime(abs(b - i))){
cout << "3 \n" << a << " " << i << " " << b;
return 0;
}
}
}
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... |