CF1550D.Excellent Arrays

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Let's call an integer array a1,a2,…,ana_1, a_2, \dots, a_n good if ai≠ia_i \neq i for each ii.

Let F(a)F(a) be the number of pairs (i,j)(i, j) (1≤i<j≤n1 \le i \lt j \le n) such that ai+aj=i+ja_i + a_j = i + j.

Let's say that an array a1,a2,…,ana_1, a_2, \dots, a_n is excellent if:

  • aa is good;
  • l≤ai≤rl \le a_i \le r for each ii;
  • F(a)F(a) is the maximum possible among all good arrays of size nn.

Given nn, ll and rr, calculate the number of excellent arrays modulo 109+710^9 + 7.

我们称一个整数数组 a1,a2,…,ana_1, a_2, \dots, a_n 是好的,如果对每个 ii 都有 ai≠ia_i \neq i。

令 F(a)F(a) 表示满足 ai+aj=i+ja_i + a_j = i + j 的数对 (i,j)(i, j)(其中 1≤i<j≤n1 \le i \lt j \le n)的个数。

我们称一个数组 a1,a2,…,ana_1, a_2, \dots, a_n 是优秀的,如果:

  • aa 是好的;
  • 对每个 ii,都有 l≤ai≤rl \le a_i \le r;
  • F(a)F(a) 在所有长度为 nn 的好数组中达到最大可能值。

给定 nn、ll 和 rr,请计算优秀数组的个数,并对 109+710^9 + 7 取模。

输入格式

The first line contains a single integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases.

The first and only line of each test case contains three integers nn, ll, and rr (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5; −109≤l≤1-10^9 \le l \le 1; n≤r≤109n \le r \le 10^9).

It's guaranteed that the sum of nn doesn't exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 表示测试用例的数量。

每个测试用例仅有一行,包含三个整数 nn、ll 和 rr(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5;−109≤l≤1-10^9 \le l \le 1;n≤r≤109n \le r \le 10^9)。

保证所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, print the number of excellent arrays modulo 109+710^9 + 7.

对于每个测试用例,输出优秀数组的数量对 109+710^9 + 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)F(a) among all good arrays aa is equal to 22. The excellent arrays are:

  1. [2,1,2][2, 1, 2];
  2. [0,3,2][0, 3, 2];
  3. [2,3,2][2, 3, 2];
  4. [3,0,1][3, 0, 1].

在第一个测试用例中,可以证明所有“好”数组 aa 中最大的 F(a)F(a) 等于 22。这些“极好”数组为:

  1. [2,1,2][2, 1, 2];
  2. [0,3,2][0, 3, 2];
  3. [2,3,2][2, 3, 2];
  4. [3,0,1][3, 0, 1]。

输入解题思路,AI测评打分。不知道怎么写?

首页