Submission #87772

#TimeUsernameProblemLanguageResultExecution timeMemory
87772JustInCaseBrunhilda’s Birthday (BOI13_brunhilda)C++17
40 / 100
1092 ms1236 KiB
#include <bits/stdc++.h> const int32_t MAX_N = 1e7; const int32_t MAX_M = 1e5; int32_t p[MAX_M + 5]; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int32_t m, q; std::cin >> m >> q; int64_t lcm = 1; int32_t maxP; for(int32_t i = 0; i < m; i++) { std::cin >> p[i]; if(lcm <= MAX_N) { lcm *= (int64_t) p[i]; } } std::sort(p, p + m); for(int32_t i = 0; i < q; i++) { int32_t n; std::cin >> n; if(n >= lcm) { std::cout << "oo" << '\n'; } else { int32_t ans = 0; while(n > 0) { int32_t curr = 0; for(int32_t j = m - 1; j >= 0; j--) { curr = std::max(curr, n % p[j]); } ans++; n -= curr; } std::cout << ans << '\n'; } } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:16:10: warning: unused variable 'maxP' [-Wunused-variable]
  int32_t maxP;
          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...