CF1924D.Balanced Subsequences

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.

A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.

You are given three integers nn , mm and kk . Find the number of sequences consisting of nn '(' and mm ')', such that the longest balanced subsequence is of length 2k2 \cdot k . Since the answer can be large calculate it modulo 10000000071\,000\,000\,007 ( 109+710^9 + 7 ).

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t31031 \le t \le 3 \cdot 10^3 ). Description of the test cases follows.

The first line of each test case contains three integers nn , mm and kk ( 1n,m,k21031 \le n, m, k \le 2 \cdot 10^3 )

输出格式

For each test case, print one integer — the answer to the problem.

输入输出样例

  • 输入#1

    3
    2 2 2
    3 2 3
    3 2 1

    输出#1

    2
    0
    4

说明/提示

For the first test case "()()", "(())" are the 22 sequences

For the second test case no sequence is possible.

For the third test case ")((()", ")(()(", ")()((", "())((" are the 44 sequences.

首页