Re: [gcj] Re: 2020 1B P1 Expogo: solution using bitwise operations. (fails with WA though). Am I wrong with the approach or is just a bug in code?

2020-04-22 Thread Alexander Iskhakov
Hi Vikram, Thanks a lot for your answer, that explains what is wrong! Indeed, the transform() cannot be that "greedy" as I thought. On Wednesday, 22 April 2020 03:17:24 UTC+8, Aditya Vikram Jain wrote: > > Hi Alexander, > > I used similar approach and I think I found out why it is wrong,

Re: [gcj] Re: 2020 1B P1 Expogo: solution using bitwise operations. (fails with WA though). Am I wrong with the approach or is just a bug in code?

2020-04-21 Thread Aditya Vikram Jain
Hi Alexander, I used similar approach and I think I found out why it is wrong, basically the solution just assumes that we need to convert the solution into two numbers which on xored give 0 and and the or operation between the two gives 2^(n-1), but this approach marks many possible answers

[gcj] Re: 2020 1B P1 Expogo: solution using bitwise operations. (fails with WA though). Am I wrong with the approach or is just a bug in code?

2020-04-21 Thread Alexander Iskhakov
> > Quickly refactored the code: > import java.io.{BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter} import java.util.Scanner object Solution { private def isPowerOf2(x: Long) = (x & (x - 1L)) == 0L /** * returns next power of 2 greater then x. * Example: