CF2200H.Six Seven

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For positive integers ii and jj, define fi(j)f_i(j) as the maximum integer kk such that iki^k divides jj. A number jj is considered special if f6(j)>f7(j)f_6(j) \gt f_7(j). For example, 66 is special, but 6767 and 77 are not.

You are given an array aa of nn positive integers. In one operation, you must increase every element in the array by 11.

Your task is to find the minimum number of operations needed to make all elements in aa special at the same time, or determine that it is impossible.

对于正整数 ii 和 jj,定义 fi(j)f_i(j) 为满足 iki^k 整除 jj 的最大整数 kk。若一个数 jj 满足 f6(j)>f7(j)f_6(j) \gt f_7(j),则称其为特殊数。例如,66 是特殊数,但 6767 和 77 不是。

给定一个包含 nn 个正整数的数组 aa。每次操作中,你必须将数组中的每个元素加 11。

你的任务是求出使数组 aa 中所有元素同时变为特殊数所需的最少操作次数;若不可能实现,则判定为无解。

输入格式

The first line contains an integer tt (1≤t≤1041 \leq t \leq 10^4), the number of test cases.

For each test case, the first line contains an integer nn (1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5).

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \leq a_i \leq 10^9).

The sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \leq t \leq 10^4),表示测试用例的数量。

对于每个测试用例,第一行包含一个整数 nn(1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \leq a_i \leq 10^9)。

所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output a single integer: the minimum number of operations to make all elements special at the same time, or −1-1 if it is impossible.

对于每个测试用例,输出一个整数:使所有元素同时变为“特殊”的最少操作次数;如果不可能,则输出 −1-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 55 operations results in the array [30,72][30,72], whose elements are all special.

In the fourth test case, the array becomes [9557358][9557358] after 77 operations.

在第一个测试用例中,无法同时使所有元素变为特殊元素。

在第二个测试用例中,执行 55 次操作后,数组变为 [30,72][30,72],其所有元素均为特殊元素。

在第四个测试用例中,经过 77 次操作后,数组变为 [9557358][9557358]。

输入解题思路,AI测评打分。不知道怎么写?

首页