#P9035. 「KDOI-04」Pont des souvenirs

    ID: 9921 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学洛谷原创O2优化组合数学洛谷月赛

「KDOI-04」Pont des souvenirs

Background

Although this is a C, it still is.

Problem Description

Given positive integers n,kn, k, find how many positive integer sequences aa of length nn satisfy:

  • 0<a1a2a3ank0 < a_1 \le a_2 \le a_3 \le \cdots \le a_n \le k;
  •  ij\forall\ i \not= j, ai+ajk+1a_i + a_j \le k + 1.

Output the answer modulo 109+710^9 + 7.

Input Format

This problem contains multiple test cases.

The first line contains a positive integer TT, the number of test cases.

For each test case, the input contains one line with two positive integers n,kn, k.

Output Format

For each test case, output one line with one integer, representing the answer.

5
2 2
1 3
4 5
4030 218
1145 1419

2
3
20
571656908
172735629

Hint

[Sample Explanation]

For the 11st test case, all sequences that satisfy the requirements are (1,1)(1, 1) and (1,2)(1, 2).

For the 22nd test case, all sequences that satisfy the requirements are (1)(1), (2)(2), and (3)(3).

[Constraints]

For 100%100\% of the testdata, it is guaranteed that 1T2×1051 \le T \le 2 \times 10^5, 1n,k1071 \le n, k \le 10^7.

This problem uses bundled test cases.

Subtask ID Points TT \le nn \le kk
11 88 55 5\le 5
22 33 10510^5 10710^7 =1= 1
33 =2= 2
44 88 =3= 3
55 1616 1010 200200 200\le 200
66 30003000 3000\le 3000
77 88 10410^4 10710^7 5\le 5
88 100100 105\le 10^5
99 3030 2×1052 \times 10^5 107\le 10^7

Translated by ChatGPT 5