CF2258A.Odd Eraser
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given an array a1,a2,…,an, you can apply the following operation any number of times (possibly zero):
- Choose an integer k≥1 such that 2k+1≤m and 2k+1 indices, i1,i2,…,i2k+1 (1≤i1<i2<…<i2k+1≤m), where m is the current length of the array. Then, remove the ik+1-th element from the array.
Note that after any operation, the length of the array is reduced by one, and the rest of the array is concatenated.
Let b1,b2,…,bm be the remaining array after all operations.
What is the maximum possible value of gcd(b1,b2,…,bm), where gcd of an array of integers denotes the greatest common divisor (GCD) of them?
给定一个数组 a1,a2,…,an,你可以执行以下操作任意多次(也可以不执行):
- 选择一个整数 k≥1,使得 2k+1≤m,并选择 2k+1 个下标 i1,i2,…,i2k+1(满足 1≤i1<i2<…<i2k+1≤m),其中 m 是当前数组的长度。然后,将数组中第 ik+1 个元素删除。
注意:每次操作后,数组长度减少 1,其余元素保持顺序拼接。
设所有操作结束后剩余的数组为 b1,b2,…,bm。
那么 gcd(b1,b2,…,bm) 的最大可能值是多少?其中 gcd 表示该整数数组的最大公约数(GCD)。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤500). The description of the test cases follows.
The first line of each test case contains n (1≤n≤100), denoting the size of the array.
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤500)。随后是测试用例的描述。
每个测试用例的第一行包含 n(1≤n≤100),表示数组的大小。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)。
输出格式
For each test case, output a single integer — the maximum possible value.
对于每个测试用例,输出一个整数——最大可能的值。
输入输出样例
输入#1
4 7 2 4 6 7 8 9 10 2 55 55555 4 1000000 1000 1 1000000000 5 23 32 23 32 23
输出#1
2 5 1000000 23
说明/提示
In the first test case, the given array is [2,4,6,7,8,9,10].
Choosing indices [1,3,4,6,7] results in the removal of a4=7 and the array [2,4,6,8,9,10].
Then, choosing indices [2,5,6] results in the removal of a5=9 and the array [2,4,6,8,10]. You can't get an answer greater than 2.
在第一个测试用例中,给定的数组为 [2,4,6,7,8,9,10]。
选择下标 [1,3,4,6,7],将移除 a4=7,得到数组 [2,4,6,8,9,10]。
接着,选择下标 [2,5,6],将移除 a5=9,得到数组 [2,4,6,8,10]。你无法得到大于 2 的答案。
输入解题思路,AI测评打分。不知道怎么写?