CF1787B.Number Factorization
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given an integer n.
Consider all pairs of integer arrays a and p of the same length such that n=∏aipi (i.e. a1p1⋅a2p2⋅…) (ai>1;pi>0) and ai is the product of some (possibly one) distinct prime numbers.
For example, for n=28=22⋅71=41⋅71 the array pair a=[2,7], p=[2,1] is correct, but the pair of arrays a=[4,7], p=[1,1] is not, because 4=22 is a product of non-distinct prime numbers.
Your task is to find the maximum value of ∑ai⋅pi (i.e. a1⋅p1+a2⋅p2+…) over all possible pairs of arrays a and p. Note that you do not need to minimize or maximize the length of the arrays.
给定一个整数 n。
考虑所有满足以下条件的整数数组对 (a,p)(两数组长度相同):
n=∏aipi(即 a1p1⋅a2p2⋅…),
其中 ai>1,pi>0,且每个 ai 是若干个(可能仅一个)互不相同的素数的乘积。
例如,对 n=28=22⋅71=41⋅71,数组对 a=[2,7]、p=[2,1] 是合法的;但数组对 a=[4,7]、p=[1,1] 不合法,因为 4=22 是非互异素数的乘积(素因子 2 重复出现)。
你的任务是:在所有可能的数组对 (a,p) 中,求 ∑ai⋅pi(即 a1⋅p1+a2⋅p2+…)的最大值。注意:你无需最小化或最大化数组的长度。
输入格式
Each test contains multiple test cases. The first line contains an integer t (1≤t≤1000) — the number of test cases.
Each test case contains only one integer n (2≤n≤109).
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤1000)—— 测试用例的数量。
每个测试用例仅包含一个整数 n(2≤n≤109)。
输出格式
For each test case, print the maximum value of ∑ai⋅pi.
对于每个测试用例,输出 ∑ai⋅pi 的最大值。
输入输出样例
输入#1
7 100 10 864 130056192 1000000000 2 999999018
输出#1
20 10 22 118 90 2 333333009
说明/提示
In the first test case, 100=102 so that a=[10], p=[2] when ∑ai⋅pi hits the maximum value 10⋅2=20. Also, a=[100], p=[1] does not work since 100 is not made of distinct prime factors.
In the second test case, we can consider 10 as 101, so a=[10], p=[1]. Notice that when 10=21⋅51, ∑ai⋅pi=7.
在第一个测试用例中,100=102,因此当 ∑ai⋅pi 取得最大值 10⋅2=20 时,有 a=[10],p=[2]。另外,a=[100]、p=[1] 不满足条件,因为 100 并非由互不相同的质因数构成。
在第二个测试用例中,可将 10 视为 101,因此 a=[10],p=[1]。注意,当 10=21⋅51 时,∑ai⋅pi=7。
输入解题思路,AI测评打分。不知道怎么写?