Submission #31884

# Submission time Handle Problem Language Result Execution time Memory
31884 2017-09-11T10:44:52 Z aome Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
483 ms 89904 KB
#include <bits/stdc++.h>
using namespace std;

const int M = 10000005;
const int INF = 1e9;

int n, q;
int nxt[M], res[M];
bool in[M];

int main() {
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x), in[x] = 1;
    }
    for (int i = 2; i < M; ++i) {
        if (nxt[i] || !in[i]) continue;
        for (int j = 0; j < M; j += i) nxt[j] = max(nxt[j], i);
    }
    int cur = 0;
    for (int i = 1; i < M; ++i) {
        while (cur < i) {
            if (!nxt[cur] || cur + nxt[cur] <= i) cur++;
            else break;
        }
        if (cur == i) break;
        res[i] = res[cur] + 1;
    }
    while (q--) {
        int x; scanf("%d", &x);
        if (!res[x]) printf("oo\n");
        else printf("%d\n", res[x]);
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
                           ^
brunhilda.cpp:14:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x), in[x] = 1;
                                          ^
brunhilda.cpp:30:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                               ^
# Verdict Execution time Memory Grader output
1 Correct 53 ms 89904 KB Output is correct
2 Correct 156 ms 89904 KB Output is correct
3 Correct 106 ms 89904 KB Output is correct
4 Correct 93 ms 89904 KB Output is correct
5 Correct 183 ms 89904 KB Output is correct
6 Correct 63 ms 89904 KB Output is correct
7 Correct 109 ms 89904 KB Output is correct
8 Correct 96 ms 89904 KB Output is correct
9 Correct 169 ms 89904 KB Output is correct
10 Correct 209 ms 89904 KB Output is correct
11 Correct 226 ms 89904 KB Output is correct
12 Correct 86 ms 89904 KB Output is correct
13 Correct 336 ms 89904 KB Output is correct
14 Correct 376 ms 89904 KB Output is correct
15 Correct 176 ms 89904 KB Output is correct
16 Correct 166 ms 89904 KB Output is correct
17 Correct 156 ms 89904 KB Output is correct
18 Correct 106 ms 89904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 89904 KB Output is correct
2 Correct 149 ms 89904 KB Output is correct
3 Correct 369 ms 89904 KB Output is correct
4 Correct 199 ms 89904 KB Output is correct
5 Correct 293 ms 89904 KB Output is correct
6 Correct 146 ms 89904 KB Output is correct
7 Correct 136 ms 89904 KB Output is correct
8 Correct 219 ms 89904 KB Output is correct
9 Correct 363 ms 89904 KB Output is correct
10 Correct 416 ms 89904 KB Output is correct
11 Correct 406 ms 89904 KB Output is correct
12 Correct 209 ms 89904 KB Output is correct
13 Correct 103 ms 89904 KB Output is correct
14 Correct 206 ms 89904 KB Output is correct
15 Correct 289 ms 89904 KB Output is correct
16 Correct 139 ms 89904 KB Output is correct
17 Correct 339 ms 89904 KB Output is correct
18 Correct 289 ms 89904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 346 ms 89904 KB Output is correct
2 Correct 446 ms 89904 KB Output is correct
3 Correct 456 ms 89904 KB Output is correct
4 Correct 259 ms 89904 KB Output is correct
5 Correct 216 ms 89904 KB Output is correct
6 Correct 386 ms 89904 KB Output is correct
7 Correct 336 ms 89904 KB Output is correct
8 Correct 319 ms 89904 KB Output is correct
9 Correct 356 ms 89904 KB Output is correct
10 Correct 289 ms 89904 KB Output is correct
11 Correct 273 ms 89904 KB Output is correct
12 Correct 306 ms 89904 KB Output is correct
13 Correct 439 ms 89904 KB Output is correct
14 Correct 239 ms 89904 KB Output is correct
15 Correct 346 ms 89904 KB Output is correct
16 Correct 366 ms 89904 KB Output is correct
17 Correct 363 ms 89904 KB Output is correct
18 Correct 473 ms 89904 KB Output is correct
19 Correct 183 ms 89904 KB Output is correct
20 Correct 476 ms 89904 KB Output is correct
21 Correct 289 ms 89904 KB Output is correct
22 Correct 483 ms 89904 KB Output is correct
23 Correct 263 ms 89904 KB Output is correct
24 Correct 179 ms 89904 KB Output is correct
25 Correct 319 ms 89904 KB Output is correct
26 Correct 276 ms 89904 KB Output is correct
27 Correct 473 ms 89904 KB Output is correct
28 Correct 173 ms 89904 KB Output is correct
29 Correct 466 ms 89904 KB Output is correct
30 Correct 403 ms 89904 KB Output is correct
31 Correct 226 ms 89904 KB Output is correct
32 Correct 263 ms 89904 KB Output is correct
33 Correct 153 ms 89904 KB Output is correct
34 Correct 326 ms 89904 KB Output is correct
35 Correct 209 ms 89904 KB Output is correct
36 Correct 409 ms 89904 KB Output is correct
37 Correct 246 ms 89904 KB Output is correct
38 Correct 343 ms 89904 KB Output is correct
39 Correct 196 ms 89904 KB Output is correct
40 Correct 323 ms 89904 KB Output is correct
41 Correct 253 ms 89904 KB Output is correct
42 Correct 359 ms 89904 KB Output is correct