题意
T次询问,每次给定a,问满足的 X 有多少个?
思路
式子化为,有异或性质可知 x 的取值为: a 的二进制中为 1 的位置选取任意个。
比如:a=101,那么x可取:000,001,100,101。
假设 a 中有 n 个1,那么答案就是.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
typedef long long LL;
int main()
{
int T; scanf("%d", &T);
while (T--)
{
LL a; scanf("%lld", &a);///a-x = a^x
int t = __builtin_popcount(a);
printf("%lld\n", 1LL<<t);
}
return 0;
}
/*
3
0
2
1073741823
*/