提示: 欢迎访问OurACM平台。
Problem 2067 Cone

Accept: 13    Submit: 130
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

kk make a cone by a paper, Paper thickness is negligible. A ant and some food at conical surface. The ant is at conical inner surface, but the food is at outer surface of the cone. now the ant want to get the food as faster as possible, can you tell it the shortest distance between ANT and FOOD.

When ant going at conical inner surface, it would only go further and further low. When ant goint at Outer surface of the cone,it would only go further and further high.

As picture ANT is at line CD, food is at line BD.

Input

There are multiple tests, each test first line contain two integer numbers r R(10<=r<R<=100, second line contain 4 float numbers w1 h1 w2 h2(0<=w1,w2<360, 0<h1,h2<R), ∠AOC = w1, ∠AOB = w2, the distance between ANT and C is h1, the distance between FOOD and B is h2.

Output

Each test output the shortest distance between ANT and FOOD.

Sample Input

20 50 30 10 60 40 50 100 60 50 180 50

Sample Output

50.26 123.93

Source

FOJ有奖月赛-2011年12月

Submit  Back  Status  Discuss