# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31863 | minhtung0404 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 436 ms | 80532 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>
const int N = 1e5 + 5;
const int M = 1e7 + 5;
const int inf = 1e9;
using namespace std;
int n, q, p[N], m, prime[M], ans[M], cnt = 1, ct;
int main(){
scanf("%d%d", &n, &q);
for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
for (int i = 1; i <= n; i++){
for (int j = 0; j < M; j+=p[i]) prime[j] = max(prime[j], p[i]);
}
ans[0] = 1;
while(ct < M){
if (ans[ct] == 0) break;
while(cnt < ct + prime[ct] && cnt < M) ans[cnt] = ans[ct] + 1, cnt++;
ct++;
}
while(q--){
scanf("%d", &m);
if (ans[m] == 0) printf("oo\n");
else printf("%d\n", ans[m]-1);
}
}
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... |