CF2238D.Storming Arasaka

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Hah, you just discovered what it takes to become a legend.

— Cyberpunk 2077

You and Johnny Silverhand decided to storm Arasaka together. After making your way through the guards, you reached Mikoshi — but in order to connect to it, you need to hack the main server.

The password to the server is formed as follows. There is a secret number nn. Consider all of its positive divisors except 11, but the divisor equal to n\mathbf{n} is considered, and partition all of them into several nonempty layers L1,L2,…,LkL_1, L_2, \ldots, L_k. A partition is called good if two conditions are satisfied:

  • for any divisor xx from layer LiL_i, all of its divisors, except 11 and xx, lie only in the layers L1,L2,…,Li−1L_1, L_2, \ldots, L_{i-1};
  • in each layer, all numbers can be ordered into a chain so that any two neighboring numbers in this chain have GCD∗^{\text{∗}} greater than 11.

The length of the password is defined as the number of layers kk. For the security of the layers, their number must be as small as possible.

Fortunately, Arasaka has not changed nn since Johnny's time, and he remembers several possible values of this number. For each of them, help V and Johnny determine the minimum possible number of layers.

∗^{\text{∗}}gcd⁡(x,y)\gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

哈哈,你刚刚发现了成为传奇所需要的一切。

——《赛博朋克2077》

你与强尼·银手决定联手突袭荒坂公司。在突破守卫之后,你们抵达了“御所”(Mikoshi)——但为了接入它,你们需要黑入主服务器。

服务器的密码构造方式如下:存在一个秘密数字 nn。考虑 nn 的所有正因数(除 11 外),但包含因数 nn 本身,并将这些因数划分为若干个非空层 L1,L2,…,LkL_1, L_2, \ldots, L_k。若一个划分满足以下两个条件,则称其为好划分:

  • 对于任意层 LiL_i 中的因数 xx,xx 的所有因数(除 11 和 xx 本身外)均仅出现在层 L1,L2,…,Li−1L_1, L_2, \ldots, L_{i-1} 中;
  • 在每一层中,所有数字均可排列成一条链,使得该链中任意两个相邻数字的 gcd⁡∗\gcd^{\text{∗}} 均大于 11。

密码的长度定义为层数 kk。为保障各层的安全性,层数必须尽可能小。

幸运的是,荒坂公司自强尼的时代以来一直未更改 nn,而他仍记得该数字的若干可能取值。对其中每一个值,请帮助V和强尼确定最小可能的层数。

∗^{\text{∗}}gcd⁡(x,y)\gcd(x, y) 表示整数 xx 与 yy 的最大公约数(GCD)。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The only line of each test case contains a single integer nn (2≤n≤1062 \le n \le 10^6) — a candidate value of the secret number that Johnny told you.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例仅有一行,包含一个整数 nn(2≤n≤1062 \le n \le 10^6)—— Johnny 告诉你的秘密数字的一个候选值。

输出格式

For each test case, output a single number — the minimum number of layers.

对于每个测试用例,输出一个数字——最小层数。

输入输出样例

  • 输入#1

    8
    2
    4
    8
    16
    32
    67
    120
    33

    输出#1

    1
    2
    3
    4
    5
    1
    7
    3

说明/提示

In the first 55 test cases, the given number has the form 2k2^k. Let us show that the answer for them is kk. Consider all positive divisors except 11: 21,22,…,2k2^1, 2^2, \ldots, 2^{k}. It is clear that no two of them can lie in the same layer, which means that all of them lie in different layers. An example of an arrangement is: Li=2iL_i = {2^i}. It is clear that it satisfies the conditions, and exactly kk layers are obtained.

在前 55 个测试用例中,给定的数形如 2k2^k。我们来证明:这些测试用例的答案为 kk。考虑除 11 外的所有正因数:21,22,…,2k2^1, 2^2, \ldots, 2^{k}。显然,其中任意两个数都不能位于同一层,因此它们全部位于不同的层中。一种可行的分层方案是:Li={2i}L_i = \{2^i\}。显然该方案满足所有条件,且恰好得到 kk 层。

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

首页