这道题可以转换为求所有数的最大公共前缀 然后就很好解决,维护公共前缀即可,最后求每个数的二进制长度与公共前缀二进制长度的差值即可 我的代码如下 #include <bits/stdc++.h> using namespace std; const int N = 100010; map<int, int> len; int a[N]; void get (int x) { int tmp = x, l = 0; while (x) { l ++; x /= 2; } len[tmp] = l; } //求两个数的最大公共前缀 int solve(int l, int a...