MWPZ033 - Kalibracja lasera - Laser calibration

no tags 

Aby przeprowadzić pomiary precyzji nowego lasera przeprowadza się następujący eksperyment. Na stole laboratoryjnym ustawia się pionowo dwa identyczne lustra, tak że tworzą one ze sobą kąt A. Zwierciadła stykają się końcami tworząc (patrząc od góry) kąt o równych ramionach. Dokładnie na końcu jednego takiego ramienia umieszczony jest laser, który emituje poziomy promień do „wnętrza” układu pod kątem B do zwierciadła, na którego końcu się znajduje. Całość układu (przykładowo dla A = 30° i B = 35°) jest przedstawiona na rysunku poniżej.

Laser

Liczba odbić promienia świetlnego zależy oczywiście od wartości kątów A i B. Okazuje się, że ta zależność, przy odpowiednio dobranych wartościach tych kątów może by wykorzystana do pomiaru precyzji lasera. Twoim zadaniem jest napisanie programu, który dla danych kątów A i B wyliczy liczbę odbić promienia świetlnego od zwierciadeł. Dla uproszczenia zakładamy, że promień nie przechodzi (poza momentem startu) przez końcówkę żadnego zwierciadła.

Wejście

W pierwszej linii pliku wejściowego znajduje się liczba naturalna d (1 ≤ d ≤ 10), określająca liczbę zestawów danych, których opisy umieszczone są kolejno po sobie w następnych liniach pliku. Opis pojedynczego zestawu jest następujący: W jedynej jego linii znajdują się dwie liczby rzeczywiste A i B (0 < A, B < 90) oznaczające odpowiednio kąt pomiędzy zwierciadłami oraz kąt pomiędzy promieniem lasera a zwierciadłem. Liczby te podane są z dokładnością do co najwyżej szóstego miejsca po przecinku.

Wyjście

Każdemu zestawowi w pliku wejściowym powinna odpowiadać jedna linia pliku wyjściowego. Ta linia powinna zawierać pojedynczą nieujemną liczbę całkowitą określającą liczbę odbić promienia od zwierciadeł.

Przykład

Wejście:
3
30.000 35.000
45.000 10.000
0.300 17.000

Wyjście:
3
3
486

 

To measure the precision of the new laser, the following experiment is performed. Two identical mirrors are placed vertically on a laboratory table so that they form an angle A with each other. The ends of the mirrors meet to form an angle with equal arms (when viewed from above). Exactly at the end of one such arm a laser is placed, which emits a beam into the "interior" of the system at an angle B to the mirror at whose end it is located. The whole system (for example for A = 30° and B = 35°) is shown in the figure below.

The number of reflections of the light beam obviously depends on the values of angles A and B. It turns out that this dependence, with appropriately chosen values of these angles, can be used to measure laser precision. Your task is to write a program that, for given angles A and B, calculates the number of reflections of the light beam from mirrors. For simplicity, we assume that the ray does not pass (except at the starting moment) through the tip of any mirror.

Input

The first line of the input file contains a natural number d (1 ≤ d ≤ 10), specifying the number of data sets whose descriptions are placed sequentially in the following lines of the file. The description of a single set is as follows: On its only line there are two real numbers A and B (0 < A, B < 90) denoting the angle between the mirrors and the angle between the laser beam and the mirror, respectively. These numbers are given to at most six decimal places.

Output

Each set in the input file should correspond to one line of the output file. This line should contain a single non-negative integer specifying the number of reflections of the ray from the mirrors. 

Example

Input:
3
30.000 35.000
45.000 10.000
0.300 17.000

Output:
3
3
486

hide comments
Oleg: 2024-04-03 03:53:52

Looks "classical" to me. What's challenge?


Added by:Rafał Witkowski
Date:2022-03-21
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All