# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491262 | ktkerem | Lutrija (COCI19_lutrija) | C++17 | 151 ms | 300 KiB |
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;
typedef long long ll;
typedef unsigned long long ull;
ll _i=0;
#define ffn(x) _i=x
#define llll pair<ll , ll>
#define stitr set<llll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
const ll limit = 1e9+7;
const ll ous=1e5 + 5;
const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1};
ll pf(ll x){
ll y = sqrt(x);
if(x == 1){
return 0;
}
for(ll i = 2;y >= i;i++){
if(x % i == 0){
return 0;
}
}
return 1;
}
void solve(){
ll l , r;
cin >> l >> r;
if(l!=2 && r!=2){
vector<ll> ans;
if(abs(r-l) == 2){
cout <<"2\n"<< l << " " << r;
return;
}
else{
ans.pb(l);
if(pf(l-2)){
// do nothing
}
else if(pf(l + 2)){
ans.pb(l+2);
}
else{
cout << -1 << "\n";
return;
}
ans.pb(2);
if(pf(r-2)){
// do nothing
}
else if(pf(r + 2)){
ans.pb(r+2);
}
else{
cout << -1 << "\n";
return;
}
ans.pb(r);
cout << ans.size() << "\n";
fora(i,ans.size()){
cout << ans[i] << " ";
}
}
}
else{
if(l != 2){
ll s= l-2;
if(pf(s)){
cout << 2 << "\n" << l << " " << r<< "\n";
}
else if(pf(s) && pf(s-2)){
cout << 3 << "\n" << l << " " << s << " " << r << "\n";
}
else if(pf(l+2)){
cout << 3 << "\n" << l <<" "<<l+2 << " " << r<< "\n";
}
else{
cout << -1 << "\n";
return;
}
}
else{
ll o = r-2;
if(pf(o)){
cout << "2\n" << l << " " << r << "\n";
}
else if(pf(o) && pf(o-2)){
cout << 3 << "\n" << l << " " << o << " " << r<< "\n";
}
else if(pf(r+2)){
cout << 3 << "\n" << l <<" "<< r+2 << " " << r<< "\n";
}
else{
cout << "-1\n";
return;
}
}
}
return;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
ll t=1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
# | 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... |