Czech ACM Student Chapter

Czech Technical University in Prague

Charles University in Prague

Technical University of Ostrava

ˇ ´

Slovak University of Technology

Pavol Jozef Safarik University in Koˇice

s

ˇ

University of Zilina

Masaryk University

Matej Bel University in Bansk´ Bystrica

a

University of West Bohemia

CTU Open Contest 2012 -- Practice Session

Charlie the Cockchafer

cockchaf.c, cockchaf.cpp, Cockchaf.java

Charlie knows how to fly. Despite this, whenever Charlie wants to move from one point to

another, it becomes a tedious task for him. The main trouble is that Charlie is a cockchafer.

And it is a well-known fact that all cockchafers (do not confuse them with cockroaches) are

clumsy and slow. Not only they need some time to fly along a straight line, they also spend

more time making turns. Knowing their limitations, will you help Charlie to find the quickest

route?

Input Specification

The input consists of several instances. The first line of each instance contains integers S and

T (1 ≤ S, T ≤ 1000), where S is Charlie's speed in meters per second, and T is the speed of

him turning in degrees per second. The second line contains four integers (0 ≤ Xf , Yf , Xt , Yt ≤

10000) indicating the starting point (Xf , Yf ) and the destination (Xt, Yt). All coordinates are

given in meters.

Output Specification

For each input instance, print a single line containing one real number R, giving the shortest time

Charlie needs to get from the initial to the final point. At the beginning, Charlie is facing north,

which is the positive direction of Y-axis. So, he first needs to turn by D degrees (0 ≤ D ≤ 180)

to an appropriate direction, then he can fly over a straight path to the final point. If the length

of the straight flight is L, the total time will be R = L/S + D/T seconds.

The answer will be accepted as correct if the difference between R and the answer computed by

the judges is at most 0.001.

Sample Input

3

10

0

0 0 10

3

10

0

0 10 10

Output for Sample Input

3.3333

9.2140