题意:
输入N , 求有多少对(a,b) gcd(a,b) == a ^ b
然而 gcd(a,b) == a ^ b = c 可以得出 b = a - c;
然后就是枚举c a 了
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn = 30000000 +131;
typedef long long LL;
LL num[maxn];
void Int() {
for(int c = 1; c <= maxn/2; ++c) //用sqrt + c*c覆盖不了全部0.0
{
for(int a = c+c; a <= maxn; a+=c)
{
if(c == (a ^ (a - c)) && (a - c))
num[a]++;
}
}
for(int i = 2; i < maxn; ++i)
num[i] += num[i-1];
}
int main() {
int T;
Int();
cin >> T;
for(int i = 1; i <= T; ++i)
{
int n;
cin >> n;
printf("Case %d: %lld\n",i,num[n]);
}
return 0;
}