CF1550D.Excellent Arrays
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call an integer array a1,a2,…,an good if ai=i for each i.
Let F(a) be the number of pairs (i,j) (1≤i<j≤n) such that ai+aj=i+j.
Let's say that an array a1,a2,…,an is excellent if:
- a is good;
- l≤ai≤r for each i;
- F(a) is the maximum possible among all good arrays of size n.
Given n, l and r, calculate the number of excellent arrays modulo 109+7.
我们称一个整数数组 a1,a2,…,an 是好的,如果对每个 i 都有 ai=i。
令 F(a) 表示满足 ai+aj=i+j 的数对 (i,j)(其中 1≤i<j≤n)的个数。
我们称一个数组 a1,a2,…,an 是优秀的,如果:
- a 是好的;
- 对每个 i,都有 l≤ai≤r;
- F(a) 在所有长度为 n 的好数组中达到最大可能值。
给定 n、l 和 r,请计算优秀数组的个数,并对 109+7 取模。
输入格式
The first line contains a single integer t (1≤t≤1000) — the number of test cases.
The first and only line of each test case contains three integers n, l, and r (2≤n≤2⋅105; −109≤l≤1; n≤r≤109).
It's guaranteed that the sum of n doesn't exceed 2⋅105.
第一行包含一个整数 t(1≤t≤1000)—— 表示测试用例的数量。
每个测试用例仅有一行,包含三个整数 n、l 和 r(2≤n≤2⋅105;−109≤l≤1;n≤r≤109)。
保证所有测试用例中 n 的总和不超过 2⋅105。
输出格式
For each test case, print the number of excellent arrays modulo 109+7.
对于每个测试用例,输出优秀数组的数量对 109+7 取模的结果。
输入输出样例
输入#1
4 3 0 3 4 -3 5 42 -33 55 69 -42 146
输出#1
4 10 143922563 698570404
说明/提示
In the first test case, it can be proven that the maximum F(a) among all good arrays a is equal to 2. The excellent arrays are:
- [2,1,2];
- [0,3,2];
- [2,3,2];
- [3,0,1].
在第一个测试用例中,可以证明所有“好”数组 a 中最大的 F(a) 等于 2。这些“极好”数组为:
- [2,1,2];
- [0,3,2];
- [2,3,2];
- [3,0,1]。
输入解题思路,AI测评打分。不知道怎么写?