# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
87772 | JustInCase | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 1092 ms | 1236 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 int32_t MAX_N = 1e7;
const int32_t MAX_M = 1e5;
int32_t p[MAX_M + 5];
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int32_t m, q;
std::cin >> m >> q;
int64_t lcm = 1;
int32_t maxP;
for(int32_t i = 0; i < m; i++) {
std::cin >> p[i];
if(lcm <= MAX_N) {
lcm *= (int64_t) p[i];
}
}
std::sort(p, p + m);
for(int32_t i = 0; i < q; i++) {
int32_t n;
std::cin >> n;
if(n >= lcm) {
std::cout << "oo" << '\n';
}
else {
int32_t ans = 0;
while(n > 0) {
int32_t curr = 0;
for(int32_t j = m - 1; j >= 0; j--) {
curr = std::max(curr, n % p[j]);
}
ans++;
n -= curr;
}
std::cout << ans << '\n';
}
}
}
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... |