题解
2026-01-17 10:32:51
发布于:浙江
14阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
unsigned int n;
int q;
cin >> n >> q;
long long total = 0;
while (q--) {
int k;
cin >> k;
int bit_pos = k - 1;
unsigned int mask = 1U << bit_pos;
if ((n & mask) == 0) {
unsigned int x = mask - (n & (mask - 1));
total += x;
n += x;
}
}
cout << total << endl;
return 0;
}
这里空空如也







有帮助,赞一个