Submission #837446

#TimeUsernameProblemLanguageResultExecution timeMemory
837446LinkedArrayLutrija (COCI19_lutrija)C++17
7 / 70
142 ms280 KiB
#include <bits/stdc++.h> using namespace std; bool isPrime(long long num){ if(num == 1) return 0; for(long long d = 2; d * d <= num; d++){ if(num % d == 0) return 0; } return 1; } int main() { long long a, b, AP2, AM2, BP2, BM2, nr; cin >> a >> b; AP2 = isPrime(a + 2); AM2 = isPrime(a - 2); BP2 = isPrime(b + 2); BM2 = isPrime(b - 2); if(a != 2 && !AP2 && !AM2) { cout << "-1"; } else if(b != 2 && !BP2 && !BM2) { cout << "-1"; } else { nr = 1 + AM2 + BM2 + 2 * (AP2 + BP2); cout << nr << '\n'; cout << (AM2 ? to_string(a) + ' ' : (AP2 ? to_string(a) + ' ' + to_string(a + 2) + ' ' : "")) << "2" << (BM2 ? ' ' + to_string(b) + ' ' : (BP2 ? to_string(b + 2) + ' ' + to_string(b) + ' ' : "")); } 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...