Please tell me the error in my code
http://www.codechef.com/viewsolution/3930436
Hey, just change
if(n&1==0)
to
if((n&1)==0)
This is a common mistake. While dealing with binary operators, β==β takes precedence over β
&
'.
Hence, β1==0β is computed before "n
&
1".
Here is the correct solution - www.codechef.com/viewsolution/3930657
guys, please upvote me. i am new here. nad not able to ask question
Thank you very much
@shainsha you cannot use Scanner
and BufferedReader
simultaneously on System.in
. That is because both Scanner
and BufferedReader
use buffers to read from the input stream. As a result when you use the Scanner
first the Scanner
's buffer is filled to itβs capacity (1024 chars), and not just what it returns. Hence what is left for the BufferedReader
in the input stream is less than what you think.
In summary, use Scanner
or BufferedReader
, but not both.