D. 幽默数(humor)

    Type: Default File IO: humor 1000ms 256MiB

幽默数(humor)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给定一个长度为 nn 的正整数序列 aa。一个正整数 xx 被称为「幽默的」,当且仅当不存在一个子区间,使得其所有元素的最小公倍数等于 xx

你需要找到最小的「幽默的」数。

序列 aa 的子区间指的是序列中的一组元素 al,al+1,,ara_l,a_{l+1},\cdots,a_r,其中 1lrn1\leq l\leq r\leq n。我们将这样的子区间表示为 [l,r][l,r]

输入格式

第一行一个整数 TT 表示数据组数。

对于每组数据,第一行一个整数 nn,第二行 nn 个整数 a1na_{1\sim n}

输出格式

对于每组数据,输出一行一个整数表示答案。

样例 1 输入

6
3
1 2 3
5
1 2 3 4 5
2
2 3
1
1000000000
12
1 8 4 2 3 5 7 2 9 10 11 13
12
7 2 5 4 2 1 1 2 3 11 8 9

样例 1 输出

4
7
1
1
16
13

样例 1 解释

在第一组样例数据中,44 是一个幽默数,并且是最小的,因为数组中出现了整数 1,2,31,2,3,这意味着存在长度为 11 的子区间,其最小公倍数分别为 1,2,31,2,3,并且不存在最小公倍数等于 44 的子区间。

在第二组样例数据中,77 是一个幽默数,整数 151\sim 5 明确出现在数组中,而整数 66 是子区间 [2,3][2,3][1,3][1,3] 的最小公倍数。

在第三组样例数据中,11 是一个幽默数,因为子区间 [1,1],[1,2],[2,2][1,1],[1,2],[2,2] 的最小公倍数分别为 2,6,32,6,3

数据规模与约定

对于 20%20\% 的数据,1n1001\leq n\leq 100

对于 40%40\% 的数据,1n10001\leq n\leq 1000

对于另外 30%30\% 的数据,1ai1051\leq a_i\leq 10^5

对于 100%100\% 的数据,1T101\leq T\leq 101n1051\leq n\leq 10^51ai1091\leq a_i\leq 10^9

0830

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2025-8-30 14:00
End at
2025-8-30 17:30
Duration
3.5 hour(s)
Host
Partic.
54