Question Link:
The same while loop gives a wrong answer on my VSCode (Windows, if that matters), while the same while loop is accepted on leetcode. What’s happening?
It is my first encounter with uint_32t, so I guess it has some relation to the WA?
#include<bits/stdc++.h>
using namespace std;
int main(){
uint32_t n;
cin>>n;
int count = 0;
while(n != 0){
if(n & 1 == 1)
count++;
n = n >> 1;
}
cout<<count;
}
The input:
00000000000000000000000000001011
Gives me 8 on VSCode while the correct answer is 3.