# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1089555 | sangeraf | Lutrija (COCI19_lutrija) | C++17 | 41 ms | 604 KiB |
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 x){
if(x==1) return 0;
for(long long i=2; i*i<=x; i++){
if(x%i==0) return 0;
}
return 1;
}
int main() {
long long a, b; cin >> a >> b;
if(max(a-b, b-a) == 2){
cout << 2 << endl << a << " " << b << endl;
return 0;
}
vector<long long> ans;
if(a>2){
if(isPrime(a-2)){
ans.push_back(a);
}else if(isPrime(a+2)){
ans.push_back(a);
ans.push_back(a+2);
}else{
cout << -1 << endl;
return 0;
}
}
ans.push_back(2);
if(b>2){
if(isPrime(b-2)){
ans.push_back(b);
}else if(isPrime(b+2)){
ans.push_back(b+2);
ans.push_back(b);
}else{
cout << -1 << endl;
return 0;
}
}
cout << ans.size() << endl;
for(int i=0; i<ans.size(); i++){
cout << ans[i] << " ";
}
cout << endl;
}
Compilation message (stderr)
# | 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... |