QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#15800. 子序列

الإحصائيات

Snuke 想要计算满足以下条件的字符串对 $(s, t)$ 的数量:

  • $s$ 恰好由 $a$ 个 $0$ 和 $b$ 个 $1$ 组成(且不包含其他字符)
  • $t$ 恰好由 $c$ 个 $0$ 和 $d$ 个 $1$ 组成(且不包含其他字符)
  • $t$ 是 $s$ 的子序列

计算这样的字符串对的数量,模 $10^9 + 7$。注意,如果可以通过从字符串 $s$ 中删除零个或多个字符,并在不改变它们相对顺序的情况下拼接剩余字符来获得字符串 $t$,则称字符串 $t$ 是字符串 $s$ 的子序列。例如,"bcef" 是 "abcdef" 的子序列。

输入格式

输入的第一行包含四个整数 $a$,$b$,$c$ 和 $d$。

数据范围

  • $0 \le a, b, c, d \le 2000$
  • $a + b > 0$
  • $c + d > 0$
  • $c \le a$
  • $d \le b$

输出格式

输出满足上述条件的字符串对的数量,模 $10^9 + 7$。

样例

输入样例 1

2 3 1 1

输出样例 1

18

输入样例 2

87 65 43 21

输出样例 2

814209149

说明

在第一个样例中,例如 $(s, t) = (\text{"01101"}, \text{"10"})$ 满足条件。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.