#P15140. [SWERC 2025] Factory Table
[SWERC 2025] Factory Table
题目描述
:::align{center}
:::
You are playing the sandbox game Mathcraft. Each crafting table of level can produce all possible products obtained by multiplying two numbers between 1 and .
If you unroll the -th crafting table, you get the array $[1 \cdot 1, 1 \cdot 2, \dots, 1 \cdot k, 2 \cdot 1, 2 \cdot 2, \dots, 2 \cdot k, \dots, k \cdot 1, k \cdot 2, \dots, k \cdot k]$. For example, for , the unrolled table is $[1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16]$.
Your friend Bob crafted a (contiguous) subarray of one unrolled crafting table. This subarray is .
You want to know how skilled Bob is, so you want to find the minimum possible level of his crafting table. Specifically, you want to determine the smallest such that appears as a subarray of the -th unrolled table.
An array is a subarray of an array if can be obtained from by deleting several (possibly zero or all) elements from the beginning and several (possibly zero or all) elements from the end.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the length of the array .
The second line of each test case contains integers ().
Note that there are no constraints on the sum of over all test cases.
输出格式
For each test case, output a single line containing an integer: the smallest crafting table level such that the array appears as a contiguous subarray of the -th unrolled table. For the given input, such a always exists.
4
4
4 6 8 10
6
8 3 6 9 12 4
5
30 40 50 60 70
4
1 2 2 4
5
4
10
2
提示
Explanation of sample 1.
In the first test case, the array is a subarray of the 5-th unrolled table, which is $[1, 2, 3, 4, 5, 2, 4, 6, 8, 10, \dots, 5, 10, 15, 20, 25]$. There is no smaller valid , so the answer is .
In the second test case, the array is a subarray of the 4-th unrolled table, which is $[1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16]$.