# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491258 | 2021-12-01T07:54:08 Z | ktkerem | Lutrija (COCI19_lutrija) | C++17 | 155 ms | 292 KB |
#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; } cout << ans.size() << "\n"; fora(i,ans.size()){ cout << ans[i] << " "; } return; } } else{ if(l != 2){ ll s= l-2; if(pf(s)){ cout << 2 << "\n" << l << " " << r; } else if(pf(l+2)){ cout << 3 << "\n" << l <<" "<<l+2 << " " << r; } else{ cout << -1 << "\n"; return; } } else{ ll o = r-2; if(pf(o)){ cout << "2\n" << l << " " << r ; } else if(pf(r+2)){ cout << 3 << "\n" << l <<" "<< r+2 << " " << r; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 138 ms | 284 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 136 ms | 284 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 155 ms | 284 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 118 ms | 292 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |