#P10154. 「FAOI-R3」移民计划

「FAOI-R3」移民计划

Problem Description

Given two positive integers n,an, a.

There are two sequences of positive integers {hn}\{h_n\}, {sn}\{s_n\} and a positive integer WW, satisfying:

$$\begin{cases} s_1=a, \\ s_i=\left\lceil \dfrac{h_{i-1}}{i} \right\rceil, \\ h_i=i \times s_i,\\ W=h_1\times h_2\times \ldots\times h_n. \end{cases}$$

Compute the value of WW. 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.

The next TT lines each contain two integers n,an, a.

Output Format

Output TT lines, each containing one integer, the answer for the corresponding test case.

7
1 1
2 4
3 9
10 6
23 44
108 301
9181918 918918
1
16
1080
721510288
57314155
568048964
118153594

Hint

Sample explanation:

  • For the 11-st test case, the sequence ss is {1}\{1\} and the sequence hh is {1}\{1\}, so the answer is 11.
  • For the 22-nd test case, the sequence ss is {4,2}\{4,2\} and the sequence hh is {4,4}\{4,4\}, so the answer is 1616.
  • For the 33-rd test case, the sequence ss is {9,5,4}\{9,5,4\} and the sequence hh is {9,10,12}\{9,10,12\}, so the answer is 10801080.
  • For the 44-th test case, the answer before taking modulo is 1672151040016721510400.

Constraints:

Test Point ID nn \le aa \le Score
11 100100 10001000 4040
22 10710^7 3030
33 10610^6

For 100%100\% of the testdata, 1T1051 \le T \le 10^5, 1n1071 \le n \le 10^7, 1a1061 \le a \le 10^6.

Translated by ChatGPT 5