Powered Addition
见浴谷题解
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
int T, n;
int INF = 1e9+1;
int ans;
// power of most significant 1
int msb(ll x) {
for (int i = 0; i < 33; i++)
if (x < (1ll << i))
return i;
}
int main() {
scanf("%d", &T);
for (int t = 0; t < T; t++) {
scanf("%d", &n);
int ceil = -INF;
ans = 0;
for (int i = 0; i < n; i++) {
int a;
scanf("%d", &a);
if (a > ceil) ceil = a;
else if (ceil != -INF) {
int d = ceil - a;
ans = max(ans, msb(d));
}
}
printf("%d\n", ans);
}
return 0;
}