CF1036F.Relatively Prime Powers

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Consider some positive integer xx. Its prime factorization will be of form x=2k1⋅3k2⋅5k3⋅…x = 2^{k_1} \cdot 3^{k_2} \cdot 5^{k_3} \cdot \dots

Let's call xx elegant if the greatest common divisor of the sequence k1,k2,…k_1, k_2, \dots is equal to 11. For example, numbers 5=515 = 5^1, 12=22⋅312 = 2^2 \cdot 3, 72=23⋅3272 = 2^3 \cdot 3^2 are elegant and numbers 8=238 = 2^3 (GCD=3GCD = 3), 2500=22⋅542500 = 2^2 \cdot 5^4 (GCD=2GCD = 2) are not.

Count the number of elegant integers from 22 to nn.

Each testcase contains several values of nn, for each of them you are required to solve the problem separately.

考虑某个正整数 xx,其质因数分解形式为 x=2k1⋅3k2⋅5k3⋅…x = 2^{k_1} \cdot 3^{k_2} \cdot 5^{k_3} \cdot \dots。

若序列 k1,k2,…k_1, k_2, \dots 的最大公约数(GCD)等于 11,则称 xx 是优美的(elegant)。例如,数字 5=515 = 5^1、12=22⋅312 = 2^2 \cdot 3、72=23⋅3272 = 2^3 \cdot 3^2 是优美的;而 8=238 = 2^3(GCD = 33)、2500=22⋅542500 = 2^2 \cdot 5^4(GCD = 22)则不是优美的。

请计算区间 [2,n][2, n] 中优美整数的个数。

每个测试用例包含多个 nn 值,对每个 nn 需要单独求解该问题。

输入格式

The first line contains a single integer TT (1≤T≤1051 \le T \le 10^5) — the number of values of nn in the testcase.

Each of the next TT lines contains a single integer nin_i (2≤ni≤10182 \le n_i \le 10^{18}).

第一行包含一个整数 TT(1≤T≤1051 \le T \le 10^5)—— 表示测试用例中 nn 的取值个数。

接下来的 TT 行,每行包含一个整数 nin_i(2≤ni≤10182 \le n_i \le 10^{18})。

输出格式

Print TT lines — the ii-th line should contain the number of elegant numbers from 22 to nin_i.

输出 TT 行——第 ii 行应包含从 22 到 nin_i 的优美数的个数。

输入输出样例

  • 输入#1

    4
    4
    2
    72
    10

    输出#1

    2
    1
    61
    6

说明/提示

Here is the list of non-elegant numbers up to 1010:

  • 4=22,GCD=24 = 2^2, GCD = 2;
  • 8=23,GCD=38 = 2^3, GCD = 3;
  • 9=32,GCD=29 = 3^2, GCD = 2.

The rest have GCD=1GCD = 1.

以下是不超过 1010 的非优雅数列表:

  • 4=224 = 2^2,GCD=2\mathrm{GCD} = 2;
  • 8=238 = 2^3,GCD=3\mathrm{GCD} = 3;
  • 9=329 = 3^2,GCD=2\mathrm{GCD} = 2。

其余数的 GCD=1\mathrm{GCD} = 1。

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

首页