0110. Planet

Имя входного файла: planet.in
Имя выходного файла: planet.out
Ограничение по времени: 2 s
Ограничение по памяти: 64 megabytes

Our brave astronauts have recently landed on a newly-discovered planet in the Alpha Centauri system. This planet can be roughly described as a rotation ellipsoid with equatorial radius a and polar radius b. Now, two different teams of astronauts have independently founded two different bases on the surface of the planet. When this was found out, they decided to build a railroad between the bases. The question is, what is the minimal possible length of the railroad? Note that there are no seas and oceans on the planet, so the railroad can be built anywhere on the surface.

Input file

First line of the input contains two integer numbers a and b, 100 ≤ a,b ≤ 10000, 1/10<a/b<10. Each of two remaining lines of the input contains the coordinates, the latitude and the longitude, of a base. The latitude is an angle -90 ≤ φ≤ 90; by definition, the latitude of a point on the surface is equal to the angle between the normal to the surface at that point and the equatorial plane. The longitude is an angle -180 ≤ θ ≤ 180. Both coordinates are measured in degrees; they are real numbers with no more than six digits after decimal point.

Output file

The single line of output must contain single real number D – the minimal possible distance between the bases. Output D as precisely as possible.

Examples:

planet.inplanet.out
1500 1000 90 0 -90 03966.3598973326


Источник: Petrozavodsk Summer 2003. Primary Contest, Sunday, August 24
Автор: Andrew Lopatin, Nick Durov

Обсудить       Отправить решение



Версия для печати