| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 1 | 0 | 0 | 0.000% |
Kolya's grandmother from the cartoon "The Mystery of the Third Planet" baked a "small" rectangular cake. Since Kolya has many friends to share it with, the cake is really rather large. Kolya wanted to help his grandmother and cut the cake into unit squares. But he did not know that she still wanted to cover the cake with whipped cream.
The grandmother, not noticing Kolya's cuts, covered the cake with cream and cut it again. She is, however, a very old, very wise, and very artistic woman and cuts cakes in her own unique way. Specifically, she makes slanted cuts that form a square pattern among themselves, with the following rules:
Into how many pieces did Kolya and his grandmother cut the cake?
The only line of input contains five integers. First are $M$ (1ドル \le M \le 10^9$), the length of the cake (from left to right), and $N$ (1ドル \le N \le 10^9$), the width of the cake (from top to bottom). Thus, Kolya cuts the cake into $M \times N$ pieces.
Next is $S$ (1ドル \le S \le 10^9$), the area of the squares of grandmother's cuts. Note that this only applies to the pieces that are complete squares. As her cuts are slanted relative to the edges of the cake, some pieces are smaller than $S$.
The last two numbers, $P$ and $Q$ (1ドル \le P \le 10^3,ドル 1ドル \le Q \le 10^3$), describe the angle of her cuts. These mean that grandmother's first cut is made in the direction of the point that is $P$ units to the right and $Q$ units up from the corner. In other words, the angle between Kolya's and grandmother's cuts is $\mathrm{atan}(\frac{Q}{P})$.
In the late 22-nd century, when the story takes place, a new quantum law for cake cutting has been found: $\frac{S}{P^2+Q^2}$ is always a square of some rational number.
The only line for output should contain a single integer: the total number of pieces into which the cake is cut by Kolya's and his grandmother's cuts.
5 4 5 2 1
36
7 8 8 1 1
84
8 12 52 2 3
122
3 3 5 11 2
21