# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
491262 | 2021-12-01T07:58:53 Z | ktkerem | Lutrija (COCI19_lutrija) | C++17 | 151 ms | 300 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; } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 284 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 141 ms | 300 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 151 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 284 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |