I have solved this using basic geometry.While looking for better approach(if any), I read here that it can be solved using binary search.

But, I am not able to come up with any solution using binary search. Any help would be highly appreciated.

Thank you