#P4609. [FJOI2016] 建筑师

    ID: 3534 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学递推2016各省省选福建线性递推,递推式

[FJOI2016] 建筑师

Description

Xiao Z is a very famous architect. One day he received a strange task: build nn buildings on a number line, where each building’s height is an integer between 11 and nn.

Xiao Z has severe OCD; he dislikes having two buildings with the same height. Moreover, Xiao Z feels that a skyline is uniquely beautiful if, when viewed from the far left (all buildings lie to the right), exactly AA buildings are visible, and when viewed from the far right (all buildings lie to the left), exactly BB buildings are visible. Now Xiao Z wants to know how many building arrangements satisfy all of the above conditions.

Building ii is visible from the left (right) if there is no building taller than it on its left (right). Two arrangements are different if and only if there exists at least one building whose height differs between the two arrangements.

Input Format

The first line contains an integer TT, the number of test cases.
Each of the next TT lines contains three integers n,A,Bn, A, B.

Output Format

For each test case, output the answer mod 109+7\text{mod } 10^9+7.

2
3 2 2
3 1 2
2
1

Hint

For 10%10\% of the testdata: 1n101 \leq n \leq 10.

For 20%20\% of the testdata: 1n1001 \leq n \leq 100.

For 40%40\% of the testdata: 1n50000, 1T51 \leq n \leq 50000, \ 1 \leq T \leq 5.

For 100%100\% of the testdata: $1 \leq n \leq 50000, \ 1 \leq A, B \leq 100, \ 1 \leq T \leq 200000$.

Translated by ChatGPT 5