# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31885 | aome | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 533 ms | 80140 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int M = 10000005;
const int INF = 1e9;
int n, q;
int nxt[M], res[M];
int main() {
scanf("%d %d", &n, &q);
for (int i = 0; i < n; ++i) {
int x; scanf("%d", &x);
for (int j = 0; j < M; j += x) nxt[j] = max(nxt[j], x);
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |