Submission #445331

#TimeUsernameProblemLanguageResultExecution timeMemory
445331colossal_pepeLutrija (COCI19_lutrija)C++17
42 / 70
1 ms204 KiB
#include <iostream> #include <vector> using namespace std; typedef long long ll; ll a, b, ans[5]; bool isPrime(ll x) { if (x < 2) return 0; for (ll i = 2; i * i <= x; i++) { if (x%i == 0) return 0; } return 1; } bool check() { vector<int> v; for (ll i: ans) { if (i > 0) v.push_back(i); } for (int i = 1; i < v.size(); i++) { if (not isPrime(v[i]) or not isPrime(abs(v[i] - v[i - 1]))) return 0; } return 1; } bool solve() { ans[0] = a, ans[4] = b; ll c1[3] = {0, a - 2, a + 2}, c2[2] = {0, 2}, c3[4] = {0, b - 2, b + 2}; for (ll p: c1) { for (ll q: c2) { for (ll r: c3) { ans[1] = p, ans[2] = q, ans[3] = r; if (check()) return 1; } } } return 0; } int main() { cin >> a >> b; if (solve()) { int cnt = 0; for (ll i: ans) { if (i > 0) cnt++; } cout << cnt << endl; for (ll i: ans) { if (i > 0) cout << i << ' '; } cout << endl; } else { cout << -1 << endl; } return 0; }

Compilation message (stderr)

lutrija.cpp: In function 'bool check()':
lutrija.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 1; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...