| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 5 | 3 | 3 | 60.000% |
Imagine we take a stretchable square paper and cut a rectangle of size $A \times B$ along the grid lines. All squares are numbered from 1ドル$ to $A \cdot B$. From this rectangle, we cut another rectangle of size $C \times D,ドル again along the grid lines, so that sides of length $C$ are parallel to sides of length $A$. Then, we glue the sides of length $B$ together, and finally, glue the sides of length $A$ together. What we got is a torus with a rectangular hole of $C \times D$ squares cut from it. (A torus is the surface of a bagel.)
The squares of the torus are considered different if they have different numbers.
We shall now tile the external surface of this torus with a hole using stretchable dominoes. Each domino consists of two squares of two different colors: one white and one black. The squares share a common side.
Our tiling has to satisfy the following condition: if two squares of the torus which are adjacent by side belong to different dominoes, they have to be the same color: both white or both black.
Two tilings are considered different if at least one of the following two conditions is satisfied:
The first line of input contains four integers $A,ドル $B,ドル $C$ and $D$ (4ドル \le A, B \le 10^9,ドル 2ドル \le C < A,ドル 2ドル \le D < B,ドル all numbers are even).
Output the number of tilings.
4 6 2 4
4
The following picture shows one of the possible tilings in the given example.