Coins on the Board
You have a chessboard with dimensions 'N' by 'M'. The rows are numbered from '1' to 'N', and the columns from '1' to 'M'. Some cells on this board already contain coins. In one move, you can select two empty cells (r[1], c[1])
and (r[2], c[2])
such that r[1] - r[2] = DR
and c[1] - c[2] = DC
, and place one coin in each of these cells. You can perform this action as many times as you like.
Your task is to determine the maximum number of additional coins you can place on the board, not counting the coins that are already there.
Input
The first line contains five integers N
, M
, K
, DR
, and DC
, separated by spaces. Here, K
represents the number of cells that initially contain coins. Each of the following K
lines contains two integers r[i]
and c[i]
, separated by a space, indicating the row and column of the i-th cell with a coin.
Output
Output the maximum number of additional coins you can place on the board.
Constraints
1 ≤ N, M ≤ 1,000,000,000 (10^9)
1 ≤ DR, DC ≤ 1,000,000,000 (10^9)
0 ≤ K ≤ 100,000 (10^5)
1 ≤ r[j] ≤ N
1 ≤ c[j] ≤ M
All cells (
r[j]
,c[j]
) are distinct.
Notes
In the first example, you have an empty 3 by 3 board with DR = DC = 1
. In the first move, you can select the pair of cells (1, 1) and (2, 2). In the second move, you can choose (1, 2) and (2, 3). In the third move, you can select (2, 1) and (3, 2).