Logo
(追記) (追記ここまで)

31326번 - Domino on Torus 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB53360.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:

  1. at least one square of the torus is white in one tiling and black in another;
  2. at least one square of the torus is covered by dominoes in such a way that the other square covered by the same domino is $Y_{1}$ in one tiling and $Y_{2}$ in another, and $Y_{1} \ne Y_{2}$.

입력

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.

제한

예제 입력 1

4 6 2 4

예제 출력 1

4

힌트

The following picture shows one of the possible tilings in the given example.

출처

Contest > Open Cup > 2014/2015 Season > Stage 5: Grand Prix of Peterhof B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /