I have tried this code twice but it gives me wrong answer always.
Can anyone help me to know as to where I go wrong in the code ? I pass easily on the Sample input using gcc 4.8.2. CODE:
#include <stdio.h>
int main(void)
{
int t;
scanf ("%d\n", &t);
while (t--)
{
int i = 0, sum = 0, m;
scanf ("%d\n", &m);
i = 13;
while (i-- > 0)
{
if (m >= 2048)
{
m /=2048;
sum++;
}
if((m & (1 << i)) != 0)
{
sum++;
}
}
printf ("%d\n", sum);
}
return 0;
}