fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int n;
  9. cin >> n;
  10. vector<int> a(n);
  11. for (int i = 0; i < n; ++i)
  12. cin >> a[i];
  13.  
  14. for (int v : a) {
  15. int ans = 20;
  16. for (int cntAdd = 0; cntAdd <= 15; ++cntAdd) {
  17. for (int cntMul = 0; cntMul <= 15; ++cntMul) {
  18. if (((v + cntAdd) << cntMul) % 32768 == 0)
  19. ans = min(ans, cntAdd + cntMul);
  20. }
  21. }
  22. cout << ans << " ";
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5300KB
stdin
4
19 32764 10240 49
stdout
14 4 4 15