Submission #747239

#TimeUsernameProblemLanguageResultExecution timeMemory
747239TrunktyLutrija (COCI19_lutrija)C++14
42 / 70
2054 ms320 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll bool isprime(int x){ if(x==1){ return false; } for(int i=2;i<=sqrt(x);i++){ if(x%i==0){ return false; } } return true; } vector<int> ans; signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); int a,b; cin >> a >> b; bool yes = true; vector<int> v; for(int i=min(a,b);i<=max(a,b);i+=2){ if(!isprime(i)){ yes = false; } v.push_back(i); } if(yes){ if(a>b){ reverse(v.begin(),v.end()); } cout << v.size() << "\n"; for(int i:v){ cout << i << " "; } cout << "\n"; return 0; } if(a==2){ ans = {2}; } else{ if(isprime(a-2)){ ans = {a,2}; } else if(isprime(a+2)){ ans = {a,a+2,2}; } else{ cout << -1 << "\n"; return 0; } } if(b==2){ // do nothing } else{ if(isprime(b-2)){ ans.push_back(b); } else if(isprime(b+2)){ ans.push_back(b+2); ans.push_back(b); } else{ cout << -1 << "\n"; return 0; } } cout << ans.size() << "\n"; for(int i:ans){ cout << i << " "; } cout << "\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...