luogu#P5088. 矩形
矩形
Background
Xiao Ben did very well on the monthly exam. As a reward, the teacher gave him a laser pointer.
Problem Description
However, the teacher never gives Xiao Ben a prize for free. He told Xiao Ben that the angle of reflection equals the angle of incidence, and asked him to solve the following problem.
Given a rectangle whose length-to-width ratio is . A laser beam is emitted from the top-left corner, and the angle between the beam and the side of length is (). It also satisfies . Find the minimum number of reflections needed for the beam to enter (after reflections) any one of the four corners again.

Input Format
Two lines.
The first line contains two numbers and , representing the ratio of the length to the width.
The second line contains two numbers and , representing .
Output Format
One positive integer, representing the minimum number of reflections needed.
3 4
1 1
5
Hint
For of the testdata, .
For another of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5