Submission #711022

#TimeUsernameProblemLanguageResultExecution timeMemory
711022dozerLutrija (COCI19_lutrija)C++14
7 / 70
180 ms308 KiB
#include <bits/stdc++.h> using namespace std; #define sp " " #define endl "\n"; #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define pb push_back #define pii pair<int, int> #define st first #define nd second #define N 200005 #define int long long const int modulo = 1e9 + 7; bool is_prime(int num) { num = abs(num); if (num < 2) return 0; for (int i = 2; i * i <= num; i++) if (num % i == 0) return 0; return 1; } vector<int> ans; void solve(int a, int b) { ans.pb(a); if (a == b) return; if (is_prime(b - a)) solve(b, b); else if (is_prime(a - 2)) solve(2, b); else if (is_prime(a + 2)) solve(a + 2, b); } int32_t main() { fastio(); int a, b; cin>>a>>b; solve(a, b); if (ans.back() == b) { cout<<ans.size()<<endl; for (auto i : ans) cout<<i<<sp; cout<<endl; } else cout<<-1<<endl; cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " seconds\n"; }
#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...