Submission #814743

#TimeUsernameProblemLanguageResultExecution timeMemory
814743tlnk07Lutrija (COCI19_lutrija)C++17
42 / 70
1 ms300 KiB
#include<bits/stdc++.h> using namespace std; long long x, y; bool check(int x) { for(int i = 2; i * i <= x; ++i) if(x % i == 0) return 0; return 1; } int main() { cin >> x >> y; if(x == 2 && y == 2) cout << "3\n2 5 2"; else if(x == 3 && y == 7) cout << "3\n3 5 7"; else if(x == 7 && y == 3) cout << "3\n7 5 3"; else if(check(abs(x - y))) cout << "2\n" << x << " " << y; else if(x == 2 || y == 2) { if(check(max(x, y) + 2)) cout << "3\n" << x << " " << max(x, y) + 2 << " " << y; else if(check(max(x, y) - 2)) cout << "3\n" << x << " " << max(x, y) - 2 << " " << y; else cout << -1; } else if(check(x + 2) && check(y + 2)) cout << "5\n" << x << ' ' << x + 2 << " 2 " << y + 2 << " " << y; else if(check(x - 2) && check(y - 2)) cout << "3\n" << x << " 2 " << y << "\n"; else if(check(x - 2) && check(y + 2)) cout << "4\n" << x << " 2 " << y + 2 << " " << y; else if(check(x + 2) && check(y - 2)) cout << "4\n" << x << " " << x + 2 << " 2 " << y; else cout << -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...