tj
2025-08-18 07:50:31
发布于:浙江
4阅读
0回复
0点赞
#include <iostream>
using namespace std;
const int MOD = 998244353;
int hammingDistance(int x, int y) {
int xorResult = x ^ y;
int distance = 0;
while (xorResult > 0) {
xorResult &= xorResult - 1;
distance++;
}
return distance;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
int count = 0;
for (int x = 0; x <= n; ++x) {
for (int y = x + 1; y <= n; ++y) {
if (hammingDistance(x, y) <= k) {
count++;
count %= MOD;
}
}
}
cout << count << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个