#include <bits/stdc++.h> #define ld double #define ull unsigned long long #define ll long long #define pii pair <int, int> #define iiii pair <int, pii > #define mp make_pair #define INF 1000000000 #define rep(i, x) for(int (i) = 0; (i) < (x); (i)++) #define int ll inline int getint() { int x = 0, p = 1; char c = getchar(); while (c <= 32) c = getchar(); if (c == 45) p = -p, c = getchar(); while (c > 32) x = x * 10 + c - 48, c = getchar(); return x * p; } using namespace std; const int mod = 1e9 + 7; inline void reduce(int &x) { x += x >> 31 & mod; } inline int mul(int x, int y) { return 1ll * x * y % mod; } //ruogu_alter const int N = 1e5 + 5; int n, a[N]; const ll inf = 2e18; // signed main() { int t = getint(); rep(tt, t) { n = getint(); int pre = -inf, res = 0; rep(i, n) { int x = getint(); int t = x - pre; if (t < 0) { t = -t; for (int i = 0; i < 40; i++) if (x + (1ll << i + 1) - 1 >= pre) { res = max(res, i + 1); break; } } else pre = x; } printf("%d\n", res); } return 0; }
#include <bits/stdc++.h> #define ld double #define ull unsigned long long #define ll long long #define pii pair <int, int> #define iiii pair <int, pii > #define mp make_pair #define INF 1000000000 #define rep(i, x) for(int (i) = 0; (i) < (x); (i)++) #define int ll inline int getint() { int x = 0, p = 1; char c = getchar(); while (c <= 32) c = getchar(); if (c == 45) p = -p, c = getchar(); while (c > 32) x = x * 10 + c - 48, c = getchar(); return x * p; } using namespace std; const int mod = 1e9 + 7; inline void reduce(int &x) { x += x >> 31 & mod; } inline int mul(int x, int y) { return 1ll * x * y % mod; } //ruogu_alter int n, m, op[4]; // void solve() { int nn = getint(); n = (nn - 1) / 3, m = (nn - 1) % 3; int l = 0; while (n >= (1ll << l)) { n -= (1ll << l); l += 2; } int res0 = n + (1ll << l); if (!m) { printf("%lld\n", res0); return; } int res1 = (1ll << l + 1); for (int i = l - 1; i >= 0; i -= 2) { int x = (n >> i & 1) << 1 | (n >> (i - 1) & 1); res1 |= (op[x] << (i - 1)); } if (m == 1) printf("%lld\n", res1); else printf("%lld\n", res0 ^ res1); } signed main() { int t = getint(); op[0] = 0; op[1] = 2; op[2] = 3; op[3] = 1; rep(tt, t) { solve(); } return 0; }