Why does this code for Ciel and Recipet fail ?

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;
}

Thanks in advance :slight_smile:

Are you sure, that for

1 
40960

the answer is 3 ?

1 Like

@betlista

Yes the answer is not 3.

@nibnalin : Please re-read the problem statement carefully specifically this part.
“Note that if she orders the same menu twice, then it is considered as two menus are ordered.”

4096=2048+2048

=> Only 2 menus are ordered.