Whats wrong with my code? Getting wrong answer on test 3 subtask 3.
https://www.codechef.com/viewsolution/15133990
Whats wrong with my code? Getting wrong answer on test 3 subtask 3.
https://www.codechef.com/viewsolution/15133990
overflow issuesâŚdidnât you check 2nd sample case given ??
Is nât the Pseudo Code given wrong?
Subtask - 2, 3 (Authorâs Solution)
Let us try to find the binary representation of K
and the final answer and try to spot some observations based on it. (Assume below that all binary representations are N
bit long).
Let N=3
Below is the table :
K ANS
000 000
001 100
010 010
011 110
100 001
101 101
110 011
111 111
Do you spot the relationship between the two of them? Yes, the answer is simply the reverse of K
in binary representation.
Thus, we can simply find the binary representation of K
. Then try to construct the answer from the reverse of the binary representation found.
Can someone provide me an implementation of this approach ?? Thanks in advance
Is this the implementation of the above approach ??
Thatâs reversing the binary representation. And you would usually use << operator to get a power of 2.
Can someone explain the authorâs solution in details ?How he arrived at it.
Thanks in Advance