Here is my code. (CodeChef: Practical coding for everyone)
I first digitized all the numbers into the smallest odd numbers, and then assumed that their final state was in binary form, and directly calculated the number of each odd number 1. I don’t understand why this is wrong.
here is my code:
void solve(){
int n; std::cin>>n;
std::vector<int>a(n);
for(auto &e:a){
std::cin>>e;
}
int ans=0;
std::map<int,int>mp;
for(int i=0;i<n;i++){
int x=a[i],cnt=1;
while(!(x&1)){
x/=2;
cnt*=2;
}
int o=mp[x];
mp[x]+=cnt;
ans+=-__builtin_popcount(o)+__builtin_popcount(mp[x]);
std::cout<<ans<<' ';
}
std::cout<<'\n';}