Submission #910066

#TimeUsernameProblemLanguageResultExecution timeMemory
910066CyberCowLutrija (COCI19_lutrija)C++17
70 / 70
140 ms592 KiB
#include <random> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <chrono> #define fr first #define sc second #define ad push_back using namespace std; using ll = long long; mt19937 rnd(348502); const ll N = 100005; bool is_prime(ll a) { if (a < 2) return 0; for (ll i = 2; i * i <= a; i++) { if (a % i == 0) return 0; } return 1; } void solve() { ll a, b; cin >> a >> b; if (is_prime(abs(a - b))) { cout << 2 << '\n' << a << ' ' << b; } else if (a == 2) { if (is_prime(b + 2)) cout << 3 << '\n' << 2 << ' ' << b + 2 << ' ' << b; else cout << -1; } else if (b == 2) { if (is_prime(a + 2)) cout << 3 << '\n' << a << ' ' << a + 2 << ' ' << 2; else cout << -1; } else if (is_prime(a - 2) && is_prime(b - 2)) { cout << 3 << '\n' << a << ' ' << 2 << ' ' << b; } else if (is_prime(a + 2) && is_prime(b + 2)) { cout << 5 << '\n' << a << ' ' << a + 2 << ' ' << 2 << ' ' << b + 2 << ' ' << b; } else if (is_prime(a + 2) && is_prime(b - 2)) { cout << 4 << '\n' << a << ' ' << a + 2 << ' ' << 2 << ' ' << b; } else if(is_prime(a - 2) && is_prime(b + 2)) { cout << 4 << '\n' << a << ' ' << 2 << ' ' << b + 2 << ' ' << b; } else cout << -1; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll tt = 1; //cin >> tt; while (tt--) { solve(); } 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...