No.1624 Reflection in a Triangle
Problem Statement
null's house is on the $xy$ plane and is the right isosceles triangle $ABC$ with $A=(0, 0), B=(1, 0), C=(0, 1)$, entirely covered with mirrors. A light is placed at vertex $A$.
The light emits a laser. The laser is fired from point $A$ in a direction where $x, y$ are both positive, with slope $a$ ($\tan \theta = a$, where $\theta$ is the angle from the $x$-axis). When the laser hits a side, it reflects so that the angle of incidence equals the angle of reflection, and it stops when it hits any of the points $A, B, C$.
Output the vertex that the laser hits next after being fired from point $A$, and the number of sides it reflects off before hitting that vertex. If the laser does not hit any of the points $A, B, C$ within a finite number of reflections, output -1.
Constraints
Input
$a$
Output
Output the vertex that the laser hits next after being fired from point $A$, and the number of sides it reflects off before hitting that vertex, separated by a space. If the laser does not hit any of the points $A, B, C$ within a finite number of reflections, output -1. Print a newline at the end.
Sample
Sample 1
Input
1.000
Output
A 1
It reflects $1$ time off $AB$ and comes straight back.
Sample 2
Input
0.500
Output
C 2
Sample 3
Input
0.124
Output
C 528
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
null
sak