[BOJ 7108] Billiards
View as PDFThe sides of a right-angled field of size 47*73 centimeters are labeled using letters A,R,Z,D. A small ball B (its size can be ignored) is placed inside this field 13 centimeters away from the side R and 29 centimeters from the side D (see pic.3). A player places his cue on the side R at a point that is located k centimeters from the side D and straightly hits the ball B. The ball continues its movements in a straight line and, if necessary, hits the sides of the field. The deflection occurs according to the laws of physics, that is, in directions making equal angles with a line perpendicular to the reflecting side. The starting fragment of the movement of the ball is shown in pic.4.</p>
Your task is to write a program that for the given integer numbers k(0 ≤ k ≤ 73) un n(0 ≤ n < 109) would output the distance of the ball to the side R(BR) and side D (BD) after the ball has moved exactly n centimeters. The values BR and BD must be output as real numbers rounded to the nearest one thousandth of a centimeter.

Pic. 3

Pic. 4
입력 형식
출력 형식
예제 입력 1
29 100
예제 출력 1
19.000 29.000
예제 입력 2
16 20
예제 출력 2
27.142 43.142
Comments