#P10154. 「FAOI-R3」移民计划
「FAOI-R3」移民计划
Problem Description
Given two positive integers .
There are two sequences of positive integers , and a positive integer , 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 . Output the answer modulo .
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , the number of test cases.
The next lines each contain two integers .
Output Format
Output 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 -st test case, the sequence is and the sequence is , so the answer is .
- For the -nd test case, the sequence is and the sequence is , so the answer is .
- For the -rd test case, the sequence is and the sequence is , so the answer is .
- For the -th test case, the answer before taking modulo is .
Constraints:
| Test Point ID | Score | ||
|---|---|---|---|
For of the testdata, , , .
Translated by ChatGPT 5