把表打出来,打满足条件的a.b和他们的gcd也就是(a^b).
发现满足条件的a - b = gcd(a,b) = a^b;
令a-b = c;
那么gcd(a,a-c)=c:
就是a ^c = a- c;
枚举c.
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
freopen("gcd.in","r",stdin);
freopen("gcd.out","w",stdout);
scanf("%d",&n);
for(int c = 1; c <= n; c++)
for(int i = n/c; i >= 2; i--)
{
int a = c* i;
if(a - c == (a^c))
{
ans ++;
}
}
cout << ans;
return 0;
}
//打出表来的我看出了规律的我并不知道怎么枚举。。。。。。