Programming contests

DEIK Regionális Programozó Csapatverseny, egyetemi kategória, 2024. december 1.

December 1, 2024, 10:00 AM – December 1, 2024, 3:00 PM

Fly

There is a market in the capital city. Three carts (C1,C2,C3C_{1},C_{2},C_{3}) simultaneously start heading toward the market (MM). The carts travel along straight paths toward the market at speeds v1,v2,v3kmhv_{1}, v_{2}, v_{3}\ \ \frac{\text{km}}{\text{h}}, respectively.

At the moment of departure, a fly located at point LL starts flying along a straight line at speed vLkmhv_{L} \frac{\text{km}}{\text{h}}, visiting the carts in the sequence C1,C2,C3,C1,C2,C3,C1,C_{1},C_{2},C_{3},C_{1},C_{2},C_{3},C_{1},\ldots, continuing this pattern as long as all carts remain farther than a distance dd from the market. We can assume that as soon as the fly reaches a cart, it immediately starts flying toward the next cart in the sequence without any delay.

Péter’s task is to calculate the total distance flown by the fly. Unfortunately, Péter is not very good at physics and has no idea where to start—let’s help him.

The carts, the market, and the fly are considered points on a plane, with coordinates measured in kilometers.

Input specification

The first three lines each contain three numbers: Ci,x,Ci,y,vii=1,2,3C_{i,x},C_{i,y},v_{i}\ \ \ i=1,2,3. The fourth line contains the coordinates of the market, Mx,MyM_{x}, M_{y}, and the distance dd. The fifth line contains the starting position and speed of the fly, Lx,LyL_{x},L_{y} and vLv_{L}. The numbers on each line are separated by spaces. All values are integers.

Output specification

The distance flown by the fly, rounded to 2 decimal places.

Constraints

1_000Ci,x,Ci,y1_000-1\_000\le C_{i,x},C_{i,y} \le 1\_000
1_000Mx,My1_000-1\_000\le M_{x},M_{y} \le 1\_000
1d101\le d \le 10
1_000Lx,Ly1_000-1\_000\le L_{x},L_{y} \le 1\_000
1vi1001\le v_{i} \le 100
1vL100_0001\le v_{L} \le 100\_000

Sample input 1

  1. -10 0 1
  2. 10 0 1
  3. 10 0 1
  4. 0 0 1
  5. -10 0 2
download as text file

Sample output 1

  1. 18.00
download as text file

Sample input 2

  1. -4 3 1
  2. 4 3 2
  3. 4 -3 3
  4. 0 0 1
  5. -4 4 6
download as text file

Sample output 2

  1. 8.00
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024