Submission #637241

#TimeUsernameProblemLanguageResultExecution timeMemory
637241ieeLutrija (COCI19_lutrija)C++17
70 / 70
341 ms340 KiB
// iee #include <bits/stdc++.h> #define rep(i, a, b) for (auto i = (a); i <= (b); ++i) #define per(i, a, b) for (auto i = (a); i >= (b); --i) #define fi first #define se second using ll = long long; using ull = unsigned long long; using namespace std; void work(int); template <class T> void read(T &x) { x = 0; int f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar(); x *= f; } int main() { int TT = 1; // cin >> TT; rep(CAS, 1, TT) work(CAS); return 0; } bool isp(ll x) { if (x <= 1) return 0; rep(i, 2, x / i) if (x % i == 0) return 0; return 1; } void work(int CASE) { ll a, b; cin >> a >> b; if (a != 2 && !isp(a - 2) && !isp(a + 2)) { puts("-1"); return; } if (b != 2 && !isp(b - 2) && !isp(b + 2)) { puts("-1"); return; } vector<ll> ans; if (isp(a - 2)) ans.push_back(a); else if (isp(a + 2)) ans.push_back(a), ans.push_back(a + 2); ans.push_back(2); if (isp(b - 2)) ans.push_back(b); else if (isp(b + 2)) ans.push_back(b + 2), ans.push_back(b); cout << ans.size() << '\n'; for (ll x: ans) cout << x << ' '; }
#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...