Submission #1126176

#TimeUsernameProblemLanguageResultExecution timeMemory
1126176MuhammetBrunhilda’s Birthday (BOI13_brunhilda)C++20
20 / 100
82 ms40464 KiB
#include <bits/stdc++.h> using namespace std; int n, q; vector <int> a, dp(10000000, -1); int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> q; a.resize(n+1); long long s = 1; for(int i = 1; i <= n; i++){ cin >> a[i]; if(s > 1e7) continue; s *= a[i]; } dp[0] = 0; for(int i = 1; i <= (1e7)/n; i++){ int k = 0; for(int j = 1; j <= n; j++){ k = max(k, (i%a[j])); } if(k == 0) continue; dp[i] = dp[i-k] + 1; } while(q--){ int x; cin >> x; if(x >= s) cout << "oo\n"; else cout << dp[x] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...