# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155753 | EntityIT | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 486 ms | 79224 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;
using LL = long long;
const int NPrime = (int)1e5 + 5, NQuery = NPrime, MAX = (int)1e7 + 5;
int nPrime, nQuery, maxPrime[MAX], f[MAX], LIM = 1;
int main() {
scanf(" %d %d", &nPrime, &nQuery);
for (int i = 1; i <= nPrime; ++i) {
int p; scanf(" %d", &p);
LIM = (int)min( (LL)MAX, (LL)LIM * p);
for (int j = 0; j < MAX; j += p) maxPrime[j] = p;
}
int lst = 0, nxt = lst;
for (int i = 0; i < LIM; ++i) {
nxt = max(nxt, i + maxPrime[i] - 1);
f[i + 1] = f[i];
if (i == lst) {
++f[i + 1];
lst = nxt;
}
}
while (nQuery--) {
int inp; scanf(" %d", &inp);
if (inp >= LIM) printf("oo\n");
else printf("%d\n", f[inp]);
}
return 0;
}
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... |