Submission #725428

#TimeUsernameProblemLanguageResultExecution timeMemory
725428TheSahibLutrija (COCI19_lutrija)C++14
70 / 70
267 ms332 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define ll long long #define pii pair<ll, ll> using namespace std; const ll MAX = 1e14; ll a, b; bool isPrime(ll n){ if(n <= 1) return false; for (int i = 2; 1ll * i * i <= n; i++) { if(n % i == 0){ return false; } } return true; } vector<ll> ans; void f(ll n){ if(n == 2){ if(isPrime(b - 2)){ ans.push_back(b); } else if(b + 2 <= MAX && isPrime(b + 2)){ ans.push_back(b + 2); ans.push_back(b); } else{ ans.clear(); } return; } if(isPrime(n - 2)){ ans.push_back(2); f(2); } else if(n + 2 <= MAX && isPrime(n + 2)){ ans.push_back(n + 2); f(n + 2); } else{ ans.clear(); } } int main(){ cin >> a >> b; ans.push_back(a); f(a); if(ans.size() == 0){ cout << -1 << '\n'; } else{ cout << ans.size() << '\n'; for(ll a:ans){ cout << a << ' '; } } }
#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...