HAMSTER1  Hamster flight
There is a competition of flying hamsters in Hamsterburg. Each competing hamster is thrown from a sling. The judges rate the flight according to its length and height. Let X meters be the distance of the flight, and Y meters – maximum height to which the hamster rose during the flight. The hamster will receive K1*X + K2*Y points for such a flight. The initial speed of the hamsters is V0 m/s. Free fall acceleration is g = 10 m/s^{2}. There is no air friction. The size of the hamster and the sling are negligible. When the hamster is thrown from the sling its height is 0 meters. You should determine the angle at which the hamster must be thrown so that he receives maximum points.
Input
The first line of input contains number t – the amount of tests. Then t tests follow one per line. The description of each test consists of three integers separated by single spaces. The first integer is V0, the second – K1, the third – K2.
Constraints
1 <= t <= 10000
1 <= V0 <= 100
0 <= K1, K2 <= 1000
0 < K1 + K2
Output
For each test output the angle in radians at which the hamster must be thrown, and the amount of points it will receive. The numbers should be separated with spaces. Print the numbers with exactly three digits in the fractional part.
Example
Input: 3 10 10 0 10 0 10 10 10 10 Output: 0.785 100.000 1.571 50.000 0.908 128.078
hide comments
marethyu1:
20181229 21:18:06
In order to use binary search, I believe it's same idea as finding a peak element in an array. 

Kuba S:
20181030 16:52:31
Ternary search + double prec. got me AC in cpp.


shimul07:
20180920 14:42:25
How to get theta ? Can anybody explain,plz? 

pradeep_yadav:
20170902 12:34:14
basic calculus would do :)


sxie12:
20170710 06:37:16
Solved with ternary search on the assumption that the objective function is unimodal. Still can't figure out why that's the case though. X is unimodal and Y is monotonically increasing. The sum may be bimodal if K2 is big and K1 small. Are the constraints on K1, K2 keeping it unimodal? 

viratian_070:
20170628 12:34:01
high school mathematics...easy one 

mishra10:
20170609 10:37:52
Try to solve this problem with ternary search apart from the basic math maxima minima method.. 

razor123:
20170306 10:07:35
search space=0 to 314159265/2 for binary search 

mkfeuhrer:
20160702 14:14:12
how to do with binary search.... i did simple maths n projectile ..! 

Hemant Kumar Singh:
20160528 20:52:27
Any hints for the binary search approach? I did by the simple equation method. 
Added by:  Spooky 
Date:  20090410 
Time limit:  0.418s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  Advancement Spring 2009, http://sevolymp.uuuq.com/ 