Submission #645327

#TimeUsernameProblemLanguageResultExecution timeMemory
645327Hacv16Lutrija (COCI19_lutrija)C++17
14 / 70
5 ms484 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAX = 2e7 + 15; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; #define pb push_back #define sz(x) (int) x.size() #define fr first #define sc second #define mp make_pair #define all(x) x.begin(), x.end() #define dbg(x) cerr << #x << ": " << "[ " << x << " ]\n" ll l, r, ind[MAX]; bool notPrime[MAX], inv, pos; vector<ll> primes, ans; void Crivo(ll n){ notPrime[1] = true; for(int i = 2; i <= n; i++){ if(notPrime[i]) continue; primes.push_back(i); ind[i] = sz(primes) - 1; for(int j = 2; i * j <= n; j++) notPrime[i * j] = true; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); Crivo(1050); cin >> l >> r; if(l == r){ cout << 1 << '\n' << l << '\n'; }else if(!notPrime[abs(l - r)]){ cout << 2 << '\n' << l << ' ' << r << '\n'; }else{ for(int i = 0; i < sz(primes); i++){ int p = primes[i]; if(!notPrime[abs(p - l)] && !notPrime[abs(p - r)]){ cout << 3 << '\n' << l << ' ' << p << ' ' << r << '\n'; return 0; } } cout << -1 << '\n'; } 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...