Hi guys,
I get Wrong Answer in problem 9500 BITCNTR (Bit counts) although i passed all the provided test cases in the problem description, i don't know whats wrong!!
Can any body helps me before i go mad ? :_(
here is the code
#include <iostream>
using namespace std;
main(){
int testcases = 0, x = 0, y = 0, sum = 0;
while(cin >> testcases){
for(int i=0; i<testcases; i++){
cin >> y;
while(1){
x = y % 2;
if(x == 1) sum++;
y = y / 2;
if(y == 0) break;
}
cout << sum << "\n";
sum = 0;
}
}
}
This code passes this test case:
5
2
3
1
0
11
Thanks in advance.