CF2179C.Blackslex and Number Theory
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Blackslex worked too hard and started dreaming about numbers. Solve the following task from his dreams.
You are given an array a1,a2,…,an.
In one operation you choose an index i (1≤i≤n) and an integer x which is at least k and set $$ a_i := a_i \bmod x, $$ where umodv denotes the remainder of dividing u by v.
Your goal is to make all elements of the array identical. Among all positive integers k, determine the maximum k for which there exists a finite sequence of the above operations that makes all array elements equal.
Blackslex 工作过于辛苦,开始梦见数字。请解决他梦中出现的以下问题。
给定一个数组 a1,a2,…,an。
在一次操作中,你选择一个下标 i(1≤i≤n)和一个不小于 k 的整数 x,并执行
a_i:=a_ibmodx,
其中 umodv 表示 u 除以 v 所得的余数。
你的目标是使数组的所有元素相等。在所有正整数 k 中,求最大的 k,使得存在有限次上述操作,能将数组所有元素变为相同值。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains a single integer n (2≤n≤2⋅105).
The second line contains n integers a1,a2,…,an (1≤ai≤109, all values of a are distinct).
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例的第一行包含一个整数 n(2≤n≤2⋅105)。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109,且所有 ai 的值互不相同)。
保证所有测试用例的 n 值之和不超过 2⋅105。
输出格式
For each test case, print a single integer — the maximum positive integer k such that it is possible to make all elements of the array identical using any number of operations with moduli x restricted to k≤x.
对于每个测试用例,输出一个整数——即最大的正整数 k,使得存在若干次操作(每次操作所用模数 x 满足 k≤x),能够使数组中所有元素变为相同值。
输入输出样例
输入#1
3 3 5 7 9 2 2 3 7 11 74 5 22 52 97 82
输出#1
5 2 6
输入解题思路,AI测评打分。不知道怎么写?