CF1787B.Number Factorization

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Given an integer nn.

Consider all pairs of integer arrays aa and pp of the same length such that n=∏aipin = \prod a_i^{p_i} (i.e. a1p1⋅a2p2⋅…a_1^{p_1}\cdot a_2^{p_2}\cdot\ldots) (ai>1;pi>0a_i \gt 1;p_i \gt 0) and aia_i is the product of some (possibly one) distinct prime numbers.

For example, for n=28=22⋅71=41⋅71n = 28 = 2^2\cdot 7^1 = 4^1 \cdot 7^1 the array pair a=[2,7]a = [2, 7], p=[2,1]p = [2, 1] is correct, but the pair of arrays a=[4,7]a = [4, 7], p=[1,1]p = [1, 1] is not, because 4=224=2^2 is a product of non-distinct prime numbers.

Your task is to find the maximum value of ∑ai⋅pi\sum a_i \cdot p_i (i.e. a1⋅p1+a2⋅p2+…a_1\cdot p_1 + a_2\cdot p_2 + \ldots) over all possible pairs of arrays aa and pp. Note that you do not need to minimize or maximize the length of the arrays.

给定一个整数 nn。

考虑所有满足以下条件的整数数组对 (a,p)(a, p)(两数组长度相同):

n=∏aipi(即 a1p1⋅a2p2⋅…),n = \prod a_i^{p_i} \quad \text{(即 } a_1^{p_1} \cdot a_2^{p_2} \cdot \ldots\text{)},

其中 ai>1a_i > 1,pi>0p_i > 0,且每个 aia_i 是若干个(可能仅一个)互不相同的素数的乘积。

例如,对 n=28=22⋅71=41⋅71n = 28 = 2^2 \cdot 7^1 = 4^1 \cdot 7^1,数组对 a=[2,7]a = [2, 7]、p=[2,1]p = [2, 1] 是合法的;但数组对 a=[4,7]a = [4, 7]、p=[1,1]p = [1, 1] 不合法,因为 4=224 = 2^2 是非互异素数的乘积(素因子 22 重复出现)。

你的任务是:在所有可能的数组对 (a,p)(a, p) 中,求 ∑ai⋅pi\sum a_i \cdot p_i(即 a1⋅p1+a2⋅p2+…a_1 \cdot p_1 + a_2 \cdot p_2 + \ldots)的最大值。注意:你无需最小化或最大化数组的长度。

输入格式

Each test contains multiple test cases. The first line contains an integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases.

Each test case contains only one integer nn (2≤n≤1092 \le n \le 10^9).

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例仅包含一个整数 nn(2≤n≤1092 \le n \le 10^9)。

输出格式

For each test case, print the maximum value of ∑ai⋅pi\sum a_i \cdot p_i.

对于每个测试用例,输出 ∑ai⋅pi\sum a_i \cdot p_i 的最大值。

输入输出样例

  • 输入#1

    7
    100
    10
    864
    130056192
    1000000000
    2
    999999018

    输出#1

    20
    10
    22
    118
    90
    2
    333333009

说明/提示

In the first test case, 100=102100 = 10^2 so that a=[10]a = [10], p=[2]p = [2] when ∑ai⋅pi\sum a_i \cdot p_i hits the maximum value 10⋅2=2010\cdot 2 = 20. Also, a=[100]a = [100], p=[1]p = [1] does not work since 100100 is not made of distinct prime factors.

In the second test case, we can consider 1010 as 10110^1, so a=[10]a = [10], p=[1]p = [1]. Notice that when 10=21⋅5110 = 2^1\cdot 5^1, ∑ai⋅pi=7\sum a_i \cdot p_i = 7.

在第一个测试用例中,100=102100 = 10^2,因此当 ∑ai⋅pi\sum a_i \cdot p_i 取得最大值 10⋅2=2010\cdot 2 = 20 时,有 a=[10]a = [10],p=[2]p = [2]。另外,a=[100]a = [100]、p=[1]p = [1] 不满足条件,因为 100100 并非由互不相同的质因数构成。

在第二个测试用例中,可将 1010 视为 10110^1,因此 a=[10]a = [10],p=[1]p = [1]。注意,当 10=21⋅5110 = 2^1\cdot 5^1 时,∑ai⋅pi=7\sum a_i \cdot p_i = 7。

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

首页