Submission #202581

#TimeUsernameProblemLanguageResultExecution timeMemory
202581YojahuangLutrija (COCI19_lutrija)C++14
0 / 70
6 ms504 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; bool check(ll v) { if (v <= 1) return false; for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } int main(){ ios::sync_with_stdio(0),cin.tie(0); ll a, b; while (cin >> a >> b) { if (a == 2ll) { if (check(b - 2ll)) { cout << "2\n"; cout << a << ' ' << b << '\n'; } else if(check(b + 2ll)){ cout << "3\n"; cout << a << ' ' << b + 2ll << ' ' << b << '\n'; } else { cout << "-1\n"; } } else if(b == 2) { if (check(a - 2ll)) { cout << "2\n"; cout << a << ' ' << b << '\n'; } else if(check(a + 2ll)){ cout << "3\n"; cout << a << ' ' << a + 2ll << ' ' << b << '\n'; } else { cout << "-1\n"; } } else { if (abs(a - b) == 2) { cout << "2\n"; cout << a << ' ' << b << '\n'; }else if(abs(a - b) == 4 && check(min(a, b) + 2ll)) { ll p = (a > b) ? b + 2ll : a + 2ll; cout << "3\n"; cout << a << ' ' << p << ' ' << b << '\n'; }else { cout << "-1\n"; } } } return 0; }
#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...