0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 06:28:47 +00:00
OI-codes/Codeforces/1661/B/B.cpp

36 lines
560 B
C++

#include <iostream>
#include <cmath>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
int n, x, ans, p[25];
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= 16; i++) {
p[i] = 1 << 16 - i;
}
while (n--) {
ans = std::numeric_limits<int>::max();
cin >> x;
for (int i = 1; i <= 16; i++) {
ans = std::min(ans, i + (int)ceil(1.0 * x / p[i]) * p[i] - x);
}
cout << ans - 1 << ' ';
}
cout << endl;
return 0;
}