# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Dabbu is back from Cox’s Bazar with an obsession with Coconut. Nowadays he is so obsessed with coconut that he has bought a coconut tree. Because He has a plan to eat more coconut water as it is very good for health and it revives the inner beauty of the skin. He also has a plan to start a business with coconut. In this situation, all of a sudden, his coconut tree was broken by the storm one day. At first, Dabbu became very sad. Seeing him sad, his mother, who is a competitive programmer, suggested a solution. She told Dabbu that if Dabbu can find the length of the broken part, she will give him some money as a reward.

Now, Dabbu is very eager to find the length of the broken part. But he has limited information to retrieve the length. Help Dabbu solve this problem. Because if you help him, he will get the money from his mother and will start a coconut business.

The coconut tree has broken in a way that from the ground point A of the tree, it has broken on point B and the peak of the tree has fallen on the ground on point D creating an angle ABD.

You will be given the length from point D (the peak of the tree that fell on the ground) to point A (the root of the tree) and the angle created on the broken part of the tree. Now help Dabbu become an entrepreneur!

The first line of the input contains an integer **T** (**1 ≤ T ≤ 500000**), the number of test cases. Then, for each test case, there will be two real numbers **d** (**1 ≤ D ≤ 5000**), **a** (**0 < a ≤ 45**) the distance from **D** to **A** and the angle **ABD** respectively.

In the output, print the length of the tree. Errors less than 10^{-4} will be ignored.

Input | Output |
---|---|

1 10 30 | 37.320508 |

93% Solution Ratio

EgorKulikovEarliest,

sarthakmannaFastest, 0.2s

smak_9Lightest, 3.5 MB

joe.masterShortest, 116B

Login to submit

This problem has asked to calculate the lengths of two edges of a triangle, given the length of one ... Read more...

Criterion 2020 Round 4 Ended |