This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool isp(ll k){
if(k == 1)return true;
for(ll i = 2;i*i<=k;i++){
if(k%i == 0)return false;
}
return true;
}
map<ll,ll> mp;
int main(){
ll a,b;
cin>>a>>b;
vector<ll> ans;
bool rev = false;
if(a>b){
rev = true;
swap(a,b);
}
ans.push_back(a);
if(a == 2){
if(isp(b+2))ans = {a,b+2,b};
else if(isp(b-2))ans = {a,b-2,b};
else{
cout<<-1;
return 0;
}
}
else{
ans.clear();
for(ll i = a;i<=b&&isp(i);i+=2){
ans.push_back(i);
}
if(ans.back() != b){
cout<<-1;
return 0;
}
}
if(rev)reverse(ans.begin(),ans.end());
cout<<ans.size()<<'\n';
for(auto &i:ans)cout<<i<<' ';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |