D - Iroha and a Grid Editorial /

Time Limit: 2 sec / Memory Limit: 256 MiB

配点 : 400400

問題文

HH マス、横 WW マスのマス目があります。 いろはちゃんは、今一番左上のマス目にいます。 そして、右か下に1マス移動することを繰り返し、一番右下のマス目へと移動します。 ただし、下から AA 個以内、かつ左から BB 個以内のマス目へは移動することは出来ません。

移動する方法は何通りあるか求めてください。

なお、答えは非常に大きくなることがあるので、答えは 109+710^9+7 で割ったあまりを出力してください。

制約

  • 1H,W100,000 1 ≦ H, W ≦ 100,000
  • 1A<H 1 ≦ A < H
  • 1B<W 1 ≦ B < W

入力

入力は以下の形式で標準入力から与えられる。

HH WW AA BB

出力

移動する方法の数を 109+710^9+7 で割ったあまりを出力せよ。


入力例 1Copy

Copy
2 3 1 1

出力例 1Copy

Copy
2

2×32×3 マスありますが、左下の 11 マスには移動することができません。「右右下」、「右下右」という 22 つの移動の仕方があります。


入力例 2Copy

Copy
10 7 3 4

出力例 2Copy

Copy
3570

移動できないマスが 1212 マスあります。


入力例 3Copy

Copy
100000 100000 99999 99999

出力例 3Copy

Copy
1

入力例 4Copy

Copy
100000 100000 44444 55555

出力例 4Copy

Copy
738162020

Score : 400400 points

Problem Statement

We have a large square grid with HH rows and WW columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.

However, she cannot enter the cells in the intersection of the bottom AA rows and the leftmost BB columns. (That is, there are A×BA×B forbidden cells.) There is no restriction on entering the other cells.

Find the number of ways she can travel to the bottom-right cell.

Since this number can be extremely large, print the number modulo 109+710^9+7.

Constraints

  • 1H,W100,000 1 ≦ H, W ≦ 100,000
  • 1A<H 1 ≦ A < H
  • 1B<W 1 ≦ B < W

Input

The input is given from Standard Input in the following format:

HH WW AA BB

Output

Print the number of ways she can travel to the bottom-right cell, modulo 109+710^9+7.


Sample Input 1Copy

Copy
2 3 1 1

Sample Output 1Copy

Copy
2

We have a 2×32×3 grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: "Right, Right, Down" and "Right, Down, Right".


Sample Input 2Copy

Copy
10 7 3 4

Sample Output 2Copy

Copy
3570

There are 1212 forbidden cells.


Sample Input 3Copy

Copy
100000 100000 99999 99999

Sample Output 3Copy

Copy
1

Sample Input 4Copy

Copy
100000 100000 44444 55555

Sample Output 4Copy

Copy
738162020


2025-06-20 (Fri)
07:23:26 +00:00