제출 #31857

#제출 시각아이디문제언어결과실행 시간메모리
31857minhtung0404Brunhilda’s Birthday (BOI13_brunhilda)C++14
58.57 / 100
789 ms80532 KiB
#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(){ cin >> n >> q; for (int i = 1; i <= n; i++) cin >> p[i]; for (int i = 1; i <= n; i++){ int z = p[i]; for (int j = 0; j < M; j+=z) prime[j] = max(prime[j], z); } for (int i = 1; i < M; i++) ans[i] = -inf; while(ct < M){ while(cnt < ct + prime[ct] && cnt < M) ans[cnt] = ans[ct] + 1, cnt++; ct++; } while(q--){ cin >> m; if (ans[m] <= 0) cout << "oo\n"; else cout << ans[m] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...