You are not logged in. Please login at www.codechef.com to post your questions!

×

WA brackets "()"

This query is related to the recent long challenge's codecracker question.Can anyone please tell me why https://www.codechef.com/viewsolution/8169233 solution failed and https://www.codechef.com/viewsolution/8169229 solution passed even though there is difference in brackets between (I&1)==(K&1) in the twelth line and everything else in the two solutions is the exact same??

asked 14 Sep '15, 21:50

ohil17yo36's gravatar image

4★ohil17yo36
805
accept rate: 10%

edited 14 Sep '15, 21:51


COMPRISON(==) operator has high precedence than BITWISE AND(&) check here.

In the WA solution l&1==k&1 it will be calculated l&(1==k)*1.

For the AC solution "()" do the right job for you as they have the high precedence.

Hope you understood the difference.

link

answered 14 Sep '15, 22:15

codeman004's gravatar image

4★codeman004
7014
accept rate: 25%

edited 14 Sep '15, 22:17

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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,070
×184
×158
×20

question asked: 14 Sep '15, 21:50

question was seen: 619 times

last updated: 14 Sep '15, 22:17