Given three targets, find the launch angle whose projectile splits into three rays 25 degrees apart that strike all targets with the least speed.
Medium7GeometryMathNo attempts yetTime limit3sMemory limit256 MBA popular mobile game launches birds at targets, and it has several weapons of different colors. The red one flies along an ordinary projectile path. The yellow one also flies along a projectile path, but if the screen is touched again in mid-flight the effect of gravity almost disappears and the weapon keeps its current direction in a straight line. The blue one splits into three parts when the screen is touched again: the middle part keeps the original direction and the other two spread slightly to the left and to the right. The new weapon in this problem is a hybrid of those two.
| Figure 1 | Figure 2 | Figure 3 |
|---|---|---|
![]() | ![]() | ![]() |
| The screen is touched when the yellow weapon reaches the white circle. | The screen is touched when the blue weapon reaches the white circle. | Paths of the new weapon. |
The new weapon starts along a projectile path. At the moment the screen is touched it splits into three parts, and after the split gravity no longer acts on them, so each part travels in a straight line. The middle part keeps the velocity direction it had at the moment of the split. The other two travel 25 degrees to the left and 25 degrees to the right of that direction. The three parts hit the targets A, B and C, one each.
The weapon is always thrown from the origin (0,0). You are free to pick the throwing angle θ, the throwing speed v, and the moment of the split. The gravitational acceleration is g=9.8, lengths are measured in coordinate units and time in seconds. No force other than gravity acts on the weapon, so there is no wind. Before the split the weapon does not hit a target even if it passes through one.
Given the coordinates of the three targets, find the throwing angle θ in degrees that lets the three parts hit all three targets.
The first line contains the number of test cases T. (T≤10000)
Each of the next T lines contains one test case: six real numbers x1, y1, x2, y2, x3, y3 separated by spaces. The three targets are at (x1,y1), (x2,y2) and (x3,y3), and 500.0≤x1,x2,x3≤10000.0. The distance between any two targets is at least 5. Which part hits which target is not fixed.
For each test case print one line in the form Case i: theta. Here i is the test case number starting from 1, and θ is the throwing angle in degrees printed with six digits after the decimal point.
A throw counts as a valid solution only if it satisfies all of the following.
At least one valid solution always exists. If there is more than one valid solution, print the θ of the one that needs the smallest speed v.