Submission #152480

#TimeUsernameProblemLanguageResultExecution timeMemory
152480dolphingarlicBrunhilda’s Birthday (BOI13_brunhilda)C++14
8.10 / 100
296 ms81144 KiB
#include <bits/stdc++.h> #pragma GCC Optimize("O3") #define FOR(i, x, y) for (int i = x; i < y; i++) #define MAXN 10000001 typedef long long ll; using namespace std; ll dp[MAXN], p[100001]; int main() { iostream::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; FOR(i, 0, n) cin >> p[i]; fill(dp, dp + MAXN, -1); dp[0] = 0; FOR(i, 1, MAXN) { int indx = n - 1; while ((~indx) && i % p[indx] == 0) indx--; if (indx == -1) break; else dp[i] = dp[i - i % p[indx]] + 1; } FOR(i, 0, q) { int x; cin >> x; if (dp[x] == -1) cout << "oo\n"; else cout << dp[x] << '\n'; } return 0; }

Compilation message (stderr)

brunhilda.cpp:2:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
 #pragma GCC Optimize("O3")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...