# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60813 | RezwanArefin01 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 605 ms | 89284 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;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 1e7 + 1;
const int M = 1e5 + 1;
int m, q, d[N], p, dp[N];
int main(int argc, char const *argv[]) {
scanf("%d %d", &m, &q);
ll prod = 1; bool flag = 0;
for(int i = 0; i < m; i++) {
scanf("%d", &p);
if(prod * p <= 1e7) prod *= p;
else flag = 1;
for(int j = 0; j < N; j += p) d[j] = p;
}
int prv = 0;
for(int i = 1; i < N; i++) {
while(prv < i) {
if(!d[prv] || prv + d[prv] <= i) ++prv;
else break;
}
if(prv == i) break;
dp[i] = dp[prv] + 1;
}
while(q--) {
int x; scanf("%d", &x);
if(x >= (flag ? 1e7 : prod))
puts("oo");
else {
printf("%d\n", dp[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... |