# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
198100 | 2020-01-24T17:26:28 Z | ZwariowanyMarcin | Lutrija (COCI19_lutrija) | C++14 | 238 ms | 476 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define LL long long #define ld double #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, j, n) for(int i = j; i <= n; ++i) #define boost cin.tie(0), ios_base::sync_with_stdio(0); using namespace std; LL x, y; int z; vector <LL> ans; bool prime(LL n) { if (n <= 1) return 0; for (int i = 2; (LL) i * i <= n; ++i) if (n % i == 0) return 0; return 1; } int main() { scanf ("%lld %lld", &x, &y); if (x > y) { z = 1; swap(x, y); } if ((x & 1) && (y & 1)) { bool ok = 1; for (int i = x; i <= y; i += 2) { ans.pb(i); if (!prime(i) || ss(ans) > 30) { ok = 0; break; } } if (ok) { printf ("%d\n", ss(ans)); if (z) reverse(ans.begin(), ans.end()); for (auto it : ans) printf ("%lld ", it); exit(0); } ans.clear(); } bool ok1 = 0; bool ok2 = 0; ans.pb(x); if (x == 2) ok1 = 1; if (!ok1) { if (prime(x - 2)) { ok1 = 1; ans.pb(2); } if (!ok1) { if (prime(x + 2)) { ok1 = 1; ans.pb(x + 2); ans.pb(2); } } } if (prime(y - 2)) { ok2 = 1; ans.pb(y); } if (!ok2 && prime(y + 2)) { ok2 = 1; ans.pb(y + 2); ans.pb(y); } if (ok1 && ok2) { if (z) reverse(ans.begin(), ans.end()); printf ("%d\n", ss(ans)); for (auto it : ans) printf ("%lld ", it); exit(0); } printf ("-1\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 1 ms | 248 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 360 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 196 ms | 360 KB | Output is correct |
2 | Correct | 119 ms | 376 KB | Output is correct |
3 | Correct | 238 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 194 ms | 256 KB | Output is correct |
2 | Correct | 118 ms | 476 KB | Output is correct |
3 | Correct | 173 ms | 360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 215 ms | 360 KB | Output is correct |
2 | Correct | 110 ms | 476 KB | Output is correct |
3 | Correct | 159 ms | 476 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 152 ms | 376 KB | Output is correct |
2 | Correct | 88 ms | 376 KB | Output is correct |
3 | Correct | 59 ms | 256 KB | Output is correct |