Contest.samsu.ru :: соревнования по программированию
Русская версия || English version
Login:
Password:
Забыли пароль?
 пример поиска: Вася Пупкин
 

Problem C for Train 2

Задачу добавил: elena

Успешно сдано решений: 4

Problem C. Cosmonaut
Author: I. Ludov

Input file: input.txt     Time limit: 2 sec
Output file: output.txt     Memory limit: 64 Mb

Statement

In the year 2030 International Space Station 2 was launched. It had a torus shape to enable artificial gravity generation. (A torus is a circular tube with circular cross-section). Advanced spacesuit technology and micro-rocket engines allowed for prolonged and easy spacewalks.

During one such spacewalk a crew member was looking at the station from an open space and wondered where should he fly to get to the station surface as fast as possible. Since he was cosmonaut and not astronaut, he had good mathematics education. So after a return to the station he quickly wrote a program which constructed the shortest line from any given point in space to the surface of a given torus.

Can you do this too?

Input file format
Input file contains eleven integer numbers:
xc yc zc — coordinates of torus center,
xd yd zd — a vector collinear to torus symmetry axis,
r1 — distance from the center of the tube to the center of the torus,
r2 — radius of the tube,
x y z — coordinates of the point in space.

Output file format
Output file must contain real numbers xm ym zm — coordinates of the nearest torus point with at least 15 correct digits after decimal point. If there is more than one nearest point, output any of them.

Constraints
-10^6 xc, yc, zc, xd, yd, zd, x, y, z <= 10^6,

0 < r2 < r1 <= 10^6, |xd| + |yd| + |zd| > 0,

point (x, y, z) lies either outside the torus or on its surface.

Sample tests
Sample input 1
0 0 0
0 0 1
10 1
1 0 0
Sample output 1
9.0 0.0 0.0

Sample input 2
5 6 7 1 1 1 50 10 3 2 1
Sample output 2
32.5203582126019 5.16103228678696 -22.1982936390279

Сдать задачу

Задать вопрос жюри по этой задаче