Подразделы

Другие разделы

Дата и время

20/12/2024 17:03:14

Авторизация

Имя:
Пароль:
Зарегистрироваться
Восстановить пароль
 

printHyperjump

Ограничения: время – 2s/4s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

In novels "Stars are the cold toys" and "Star shadow" Sergey Lukyanenko described the hyperjump that is a fantastic technology allowing to travel instantly through the space almost without energy loss. Spaceship jumps at the distance of several parsecs (`Theta` constant) and this distance depends neither of the ship’s construction, nor of its mass. The jump direction doesn’t depend from velocity vector of the jump. Direction of the jump is controlled by a human pilot. Without pilot the ship will be taken off to an arbitrary place. Long travels using hyperjump technology are very dangerous, because long series of jumps may put the pilot into hyperspace euphoria so he'll make confused jumps to nowhere until the energy is over.
Ship velocity is controlled by selecting hyperjump direction vector and using additional energy. To change ship velocity by `vec{Delta\ v}` you have to make jump in the direction `vec{Delta\ v}` using additional energy `E={m|Delta\ v|^2}/2`.
Write a program that calculates a series of jumps providing traveling from one point given to another one. The total number of jumps should not be over 30.
Ship velocity in the final point should coincide with the final velocity vector. At the same time, one doesn't have to worry about the minimization of energy consumption for ship velocity changing, because this energy can be taken from the hyperspace during the jump. The distance between the start point and the final one for a single jump should be equal `Theta` constant.
Input
First line of the input file contains 2 real numbers, separated by space; they represent the `Theta` constant (`1\ ≤\ Theta\ ≤\ 20`) and the ship mass `m`, measured in tons (`100\ ≤\ m\ ≤\ 1000`). The next line contains 6 real numbers, separated by spaces; they are ship start point coordinates `(x,\ y,\ z)`, measured in parsecs and vector of ship start velocity `(v_x,\ v_y,\ v_z)`, measured in km/s. The next line also contains 6 real numbers, separated by spaces; they are the final point coordinates, measured in parsecs and the required final velocity vector in km/s. The distance between the start and final points is not exceeded `Theta`. There are following limitations for coordinates and velocities: `|x|≤1000`, `|y|≤1000`, `|z|≤1000`, `|v_x|≤100`, `|v_y|≤100`, `|v_z|≤100`.
Output
The first line of the output file should contain integer `N`, which is the amount of jumps (it is not required to be minimal) for the spaceship travel from the start point to the final one. Each of the next `N` lines of the output file should contain 4 real numbers, separated by spaces: the coordinates (in parsecs, with accuracy `10^{-6}`) of the `i`-th jump destination point and amount of additional energy (in GigaJoules, with accuracy 0.001) to change the ship velocity (`1\ ≤\ i\ ≤\ N`) during this jump. The coordinates of `N`-th point and final point should be equal.

Sample Input

10.0 200.0
0.0 0.0 0.0 –5.0 0.0 0.0
20.0 10.0 0.0 0.0 2.0 3.0

Sample Output

5
10.000000 0.000000 0.000000 0.000
20.000000 0.000000 0.000000 2500.000
20.000000 10.000000 0.000000 400.000
20.000000 10.000000 10.000000 900.000
20.000000 10.000000 0.000000 0.000
Условие задачи на русском языке
loading