Submission #83515

#TimeUsernameProblemLanguageResultExecution timeMemory
83515teomrnBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
419 ms117776 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX = 100010, VMAX = 10000000; int prime[NMAX + 10]; int lower[VMAX + 10]; int dist[VMAX + 10]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int m, q; cin >> m >> q; while (m--) { int x; cin >> x; for (int i = 0; i <= VMAX; i += x) lower[i] = x; } int act = 0, until = 0, next = 0; for (int i = 0; i <= VMAX; i++) { if (i > until) until = next, act++; if (until < i) break; dist[i] = act; if (lower[i]) next = max(next, i + lower[i] - 1); } while (q--) { int x; cin >> x; if (dist[x]) cout << dist[x] << '\n'; else cout << "oo\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...