mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 16:58:48 +00:00
B - Getting Zero
https://codeforces.com/contest/1661/submission/153184387
This commit is contained in:
parent
1f44621147
commit
3c1c434cf0
35
Codeforces/1661/B/B.cpp
Normal file
35
Codeforces/1661/B/B.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user