# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
155736 | 2019-09-30T07:26:29 Z | IOrtroiii | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 426 ms | 87416 KB |
#include <bits/stdc++.h> using namespace std; const int MX = 10 * 1000 * 1000 + 7; bool has[MX]; int nxt[MX]; int ans[MX]; int main() { int n, q; scanf("%d %d", &n, &q); for (; n > 0; n--) { int x; scanf("%d", &x); has[x] = true; } for (int i = 2; i < MX; ++i) { if (!has[i]) continue; for (int j = 0; j < MX; j += i) { nxt[j] = max(nxt[j], j + i - 1); } } int ptr = 0; for (int i = 1; i < MX; ++i) { while (ptr < i && nxt[ptr] < i) { ++ptr; } if (ptr == i) { break; } else ans[i] = ans[ptr] + 1; } for (; q > 0; q--) { int x; scanf("%d", &x); if (!ans[x]) { puts("oo"); } else { printf("%d\n", ans[x]); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 74 ms | 39544 KB | Output is correct |
2 | Correct | 154 ms | 78712 KB | Output is correct |
3 | Correct | 96 ms | 40440 KB | Output is correct |
4 | Correct | 123 ms | 78684 KB | Output is correct |
5 | Correct | 149 ms | 78568 KB | Output is correct |
6 | Correct | 71 ms | 39544 KB | Output is correct |
7 | Correct | 95 ms | 40440 KB | Output is correct |
8 | Correct | 92 ms | 43000 KB | Output is correct |
9 | Correct | 171 ms | 78684 KB | Output is correct |
10 | Correct | 176 ms | 78812 KB | Output is correct |
11 | Correct | 184 ms | 78716 KB | Output is correct |
12 | Correct | 123 ms | 78584 KB | Output is correct |
13 | Correct | 289 ms | 78560 KB | Output is correct |
14 | Correct | 266 ms | 78712 KB | Output is correct |
15 | Correct | 162 ms | 78684 KB | Output is correct |
16 | Correct | 165 ms | 78708 KB | Output is correct |
17 | Correct | 180 ms | 78816 KB | Output is correct |
18 | Correct | 140 ms | 78712 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 164 ms | 79480 KB | Output is correct |
2 | Correct | 158 ms | 87416 KB | Output is correct |
3 | Correct | 386 ms | 79608 KB | Output is correct |
4 | Correct | 160 ms | 78712 KB | Output is correct |
5 | Correct | 265 ms | 79824 KB | Output is correct |
6 | Correct | 145 ms | 78668 KB | Output is correct |
7 | Correct | 147 ms | 79576 KB | Output is correct |
8 | Correct | 162 ms | 78584 KB | Output is correct |
9 | Correct | 277 ms | 79868 KB | Output is correct |
10 | Correct | 337 ms | 79608 KB | Output is correct |
11 | Correct | 330 ms | 79068 KB | Output is correct |
12 | Correct | 201 ms | 78712 KB | Output is correct |
13 | Correct | 127 ms | 79096 KB | Output is correct |
14 | Correct | 169 ms | 78692 KB | Output is correct |
15 | Correct | 317 ms | 79384 KB | Output is correct |
16 | Correct | 158 ms | 87416 KB | Output is correct |
17 | Correct | 345 ms | 78840 KB | Output is correct |
18 | Correct | 310 ms | 80548 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 293 ms | 79692 KB | Output is correct |
2 | Correct | 337 ms | 79480 KB | Output is correct |
3 | Correct | 387 ms | 79352 KB | Output is correct |
4 | Correct | 233 ms | 78980 KB | Output is correct |
5 | Correct | 224 ms | 83280 KB | Output is correct |
6 | Correct | 317 ms | 78968 KB | Output is correct |
7 | Correct | 255 ms | 81012 KB | Output is correct |
8 | Correct | 327 ms | 79656 KB | Output is correct |
9 | Correct | 305 ms | 79692 KB | Output is correct |
10 | Correct | 231 ms | 78712 KB | Output is correct |
11 | Correct | 210 ms | 78784 KB | Output is correct |
12 | Correct | 267 ms | 78712 KB | Output is correct |
13 | Correct | 326 ms | 79352 KB | Output is correct |
14 | Correct | 222 ms | 79164 KB | Output is correct |
15 | Correct | 271 ms | 78756 KB | Output is correct |
16 | Correct | 310 ms | 78752 KB | Output is correct |
17 | Correct | 276 ms | 79480 KB | Output is correct |
18 | Correct | 334 ms | 79324 KB | Output is correct |
19 | Correct | 140 ms | 79352 KB | Output is correct |
20 | Correct | 341 ms | 79412 KB | Output is correct |
21 | Correct | 231 ms | 79352 KB | Output is correct |
22 | Correct | 394 ms | 80296 KB | Output is correct |
23 | Correct | 221 ms | 79864 KB | Output is correct |
24 | Correct | 167 ms | 79040 KB | Output is correct |
25 | Correct | 256 ms | 79052 KB | Output is correct |
26 | Correct | 241 ms | 78988 KB | Output is correct |
27 | Correct | 379 ms | 79992 KB | Output is correct |
28 | Correct | 163 ms | 78996 KB | Output is correct |
29 | Correct | 354 ms | 80324 KB | Output is correct |
30 | Correct | 356 ms | 79864 KB | Output is correct |
31 | Correct | 188 ms | 79196 KB | Output is correct |
32 | Correct | 200 ms | 79028 KB | Output is correct |
33 | Correct | 156 ms | 79096 KB | Output is correct |
34 | Correct | 289 ms | 80928 KB | Output is correct |
35 | Correct | 191 ms | 79032 KB | Output is correct |
36 | Correct | 426 ms | 80432 KB | Output is correct |
37 | Correct | 206 ms | 83332 KB | Output is correct |
38 | Correct | 302 ms | 78968 KB | Output is correct |
39 | Correct | 177 ms | 78968 KB | Output is correct |
40 | Correct | 271 ms | 79124 KB | Output is correct |
41 | Correct | 235 ms | 81912 KB | Output is correct |
42 | Correct | 332 ms | 79024 KB | Output is correct |