Submission #1026799

#TimeUsernameProblemLanguageResultExecution timeMemory
1026799VMaksimoski008Brunhilda’s Birthday (BOI13_brunhilda)C++17
2.22 / 100
247 ms41644 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e7 + 5; vector<int> dp(maxn, 1e9); signed main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int n, q; cin >> n >> q; vector<int> p(n); for(int &x : p) cin >> x; dp[0] = 0; for(int i=1; i<=1000; i++) { for(int &x : p) { if(i % x == 0) continue; dp[i] = min(dp[i], dp[(i/x)*x] + 1); } } while(q--) { int x; cin >> x; if(dp[x] < 1e9) cout << dp[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...