CF2200H.Six Seven
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For positive integers i and j, define fi(j) as the maximum integer k such that ik divides j. A number j is considered special if f6(j)>f7(j). For example, 6 is special, but 67 and 7 are not.
You are given an array a of n positive integers. In one operation, you must increase every element in the array by 1.
Your task is to find the minimum number of operations needed to make all elements in a special at the same time, or determine that it is impossible.
对于正整数 i 和 j,定义 fi(j) 为满足 ik 整除 j 的最大整数 k。若一个数 j 满足 f6(j)>f7(j),则称其为特殊数。例如,6 是特殊数,但 67 和 7 不是。
给定一个包含 n 个正整数的数组 a。每次操作中,你必须将数组中的每个元素加 1。
你的任务是求出使数组 a 中所有元素同时变为特殊数所需的最少操作次数;若不可能实现,则判定为无解。
输入格式
The first line contains an integer t (1≤t≤104), the number of test cases.
For each test case, the first line contains an integer n (1≤n≤2⋅105).
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109).
The sum of n over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。
对于每个测试用例,第一行包含一个整数 n(1≤n≤2⋅105)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)。
所有测试用例的 n 之和不超过 2⋅105。
输出格式
For each test case, output a single integer: the minimum number of operations to make all elements special at the same time, or −1 if it is impossible.
对于每个测试用例,输出一个整数:使所有元素同时变为“特殊”的最少操作次数;如果不可能,则输出 −1。
输入输出样例
输入#1
4 3 1 2 3 2 25 67 8 6 6 12 18 24 36 42 84 1 9557351
输出#1
-1 5 12 7
说明/提示
In the first test case, all elements cannot be made special at the same time.
In the second test case, performing 5 operations results in the array [30,72], whose elements are all special.
In the fourth test case, the array becomes [9557358] after 7 operations.
在第一个测试用例中,无法同时使所有元素变为特殊元素。
在第二个测试用例中,执行 5 次操作后,数组变为 [30,72],其所有元素均为特殊元素。
在第四个测试用例中,经过 7 次操作后,数组变为 [9557358]。
输入解题思路,AI测评打分。不知道怎么写?