# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
535486 | Baray | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 443 ms | 159368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define N 10000005
int sieve[N], cost[N];
int n, q;
signed main() {
cin >> n >> q;
vector<int> a(n);
int child, l = 1, mx = 0, p;
for (int i = 0; i < n; i++) {
cin >> p;
mx = max(mx, p);
for (int j = p; j < N; j += p) {
sieve[j] = p;
}
}
int cur = mx, next = 0, cur_cost = 1;
for (int i = 0; i < N; i++) {
if (i >= cur) {
if (next > cur) {
cur = next;
cur_cost++;
}
else break;
}
cost[i] = cur_cost;
if (sieve[i]) next = max(next, i + sieve[i]);
}
while (q--) {
cin >> p;
if (cost[p] == 0) {
cout << "oo\n";
continue;
}
cout << cost[p] << "\n";
}
}
컴파일 시 표준 에러 (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... |