0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

B - Getting Zero

https://codeforces.com/contest/1661/submission/153184387
This commit is contained in:
Baoshuo Ren 2022-04-09 23:16:38 +08:00
parent 1f44621147
commit 3c1c434cf0
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

35
Codeforces/1661/B/B.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <cmath>
#include <iostream>
#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;
}