×

# Why does this code for Ciel and Recipet fail ?

 0 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 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; }  asked 01 Aug '14, 22:18 6★nibnalin 161●1●5●16 accept rate: 0% Thanks in advance :) (01 Aug '14, 22:18) nibnalin6★

 0 @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. answered 02 Aug '14, 05:31 333●2●3●9 accept rate: 20%
 1 Are you sure, that for 1 40960  the answer is 3 ? answered 01 Aug '14, 22:47 16.9k●49●115●225 accept rate: 11%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,470
×538
×4

question asked: 01 Aug '14, 22:18

question was seen: 569 times

last updated: 02 Aug '14, 05:31