题目等价于异或,异或后的数字有几个1就是有几个不同,统计1可以用lowbit来统计,时间复杂度O( a,b的位数)

#include <iostream>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(false),cin.tie(0);
#define endl cout<<"\n";
const int N=1e3+7;
const int M=1e5+7;
int ans;
int a[N][N];
int n;


#define lowbit(x) x&(-x)
void solve(){
    int a,b;
    cin>>a>>b;
    a^=b;
    int ans=0;
    while(a){
        a-=lowbit(a);
        ans+=1;
    }
    cout<<ans;
}
int main(){
    IOS;
    int T=1;
    //cin>>T;
    while(T--)solve();
    return 0;
}