SRM 338 DIV 2 easy & mid

It can be solved by "binary searching."
'int' is always better than 'double.'