CF2176F.Omega Numbers
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For a given number n, consider the function ω(n), which is equal to the number of unique prime numbers in the prime factorization of the number n.
For example, ω(12)=ω(22⋅3)=2. And ω(120)=ω(23⋅3⋅5)=3.
For an array of natural numbers a and a natural number k, we define f(a,k)=∑i<jω(ai⋅aj)k for all i<j.
You are given an array of natural numbers a of length n and a natural number k. Calculate f(a,k) modulo 998244353.
对于给定的正整数 n,考虑函数 ω(n),其值等于 n 的质因数分解中不同质数的个数。
例如,ω(12)=ω(22⋅3)=2;而 ω(120)=ω(23⋅3⋅5)=3。
对于一个正整数数组 a 和一个正整数 k,我们定义
f(a,k)=i<j∑ω(ai⋅aj)k,
其中求和遍历所有满足 i<j 的下标对。
现给定一个长度为 n 的正整数数组 a 和一个正整数 k,请计算 f(a,k) 对 998244353 取模的结果。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains 2 integers n and k (1≤n≤2⋅105,1≤k≤109) —the length of the array a and the exponent of the operation, respectively.
The second line of each test case contains n natural numbers a1,a2,…,an (1≤ai≤n) —the array a.
It is guaranteed that the sum of n across all test cases does not exceed 2⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含两个整数 n 和 k(1≤n≤2⋅105,1≤k≤109),分别表示数组 a 的长度和操作的指数。
每个测试用例的第二行包含 n 个自然数 a1,a2,…,an(1≤ai≤n),即数组 a。
保证所有测试用例中 n 的总和不超过 2⋅105。
输出格式
For each test case, output a single line containing an integer — the value of the function f(a,k) modulo 998244353.
对于每个测试用例,输出一行,包含一个整数——函数 f(a,k) 对 998244353 取模的结果。
输入输出样例
输入#1
3 4 1 3 3 3 3 4 1 1 1 1 1 4 2 1 2 3 4
输出#1
6 0 12
说明/提示
Explanation of the first test case example:
For any pair (i,j), the value ω(x) for the product is ω(32)=1. There are a total of 6 pairs, and the exponent is 1. The final answer is 6.
Explanation of the second test case example:
In any pair of the second test case, the product of the numbers in the pair equals 1, so the number of primes in it is 0. Therefore, the final answer is also 0.
Explanation of the third test case example:
Consider all pairs (i,j):
- (1,2): the product of the numbers at positions 1 and 2 equals a1⋅a2=1⋅2, ω(2)=1.
- (1,3): the product of the numbers at positions 1 and 3 equals a1⋅a3=1⋅3, ω(3)=1.
- (1,4): the product of the numbers at positions 1 and 4 equals a1⋅a4=1⋅4, ω(22)=1.
- (2,3): the product of the numbers at positions 2 and 3 equals a2⋅a3=2⋅3, ω(2⋅3)=2.
- (2,4): the product of the numbers at positions 2 and 4 equals a2⋅a4=2⋅4, ω(23)=1.
- (3,4): the product of the numbers at positions 3 and 4 equals a3⋅a4=3⋅4, ω(3⋅22)=2.
In the answer, the values of ω(x) are raised to the power of 2, so 12+12+12+22+12+22=12.
第一个测试用例示例的解释:
对于任意一对 (i,j),其乘积的 ω(x) 值为 ω(32)=1。总共有 6 对,且指数为 1。最终答案为 6。
第二个测试用例示例的解释:
在第二个测试用例的所有数对中,每对数的乘积均为 1,因此其中所含的不同质因数个数为 0。故最终答案也为 0。
第三个测试用例示例的解释:
考虑所有数对 (i,j):
- (1,2):位置 1 和 2 上的数的乘积为 a1⋅a2=1⋅2,ω(2)=1。
- (1,3):位置 1 和 3 上的数的乘积为 a1⋅a3=1⋅3,ω(3)=1。
- (1,4):位置 1 和 4 上的数的乘积为 a1⋅a4=1⋅4,ω(22)=1。
- (2,3):位置 2 和 3 上的数的乘积为 a2⋅a3=2⋅3,ω(2⋅3)=2。
- (2,4):位置 2 和 4 上的数的乘积为 a2⋅a4=2⋅4,ω(23)=1。
- (3,4):位置 3 和 4 上的数的乘积为 a3⋅a4=3⋅4,ω(3⋅22)=2。
在答案中,各 ω(x) 的值需平方后求和,即 12+12+12+22+12+22=12。
输入解题思路,AI测评打分。不知道怎么写?