CF2176F.Omega Numbers

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

For a given number nn, consider the function ω(n)\omega(n), which is equal to the number of unique prime numbers in the prime factorization of the number nn.

For example, ω(12)=ω(22⋅3)=2\omega (12) = \omega (2^2 \cdot 3) = 2. And ω(120)=ω(23⋅3⋅5)=3\omega (120) = \omega (2^3 \cdot 3 \cdot 5) = 3.

For an array of natural numbers aa and a natural number kk, we define f⁡(a,k)=∑i<jω(ai⋅aj)k\operatorname{f}(a, k) = \sum_{i \lt j} \omega(a_i \cdot a_j)^k for all i<ji \lt j.

You are given an array of natural numbers aa of length nn and a natural number kk. Calculate f⁡(a,k)\operatorname{f}(a, k) modulo 998 244 353998\,244\,353.

对于给定的正整数 nn,考虑函数 ω(n)\omega(n),其值等于 nn 的质因数分解中不同质数的个数。

例如,ω(12)=ω(22⋅3)=2\omega (12) = \omega (2^2 \cdot 3) = 2;而 ω(120)=ω(23⋅3⋅5)=3\omega (120) = \omega (2^3 \cdot 3 \cdot 5) = 3。

对于一个正整数数组 aa 和一个正整数 kk,我们定义

f⁡(a,k)=∑i<jω(ai⋅aj)k,\operatorname{f}(a, k) = \sum_{i \lt j} \omega(a_i \cdot a_j)^k,

其中求和遍历所有满足 i<ji \lt j 的下标对。

现给定一个长度为 nn 的正整数数组 aa 和一个正整数 kk,请计算 f⁡(a,k)\operatorname{f}(a, k) 对 998 244 353998\,244\,353 取模的结果。

输入格式

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 first line of each test case contains 2 integers nn and kk (1≤n≤2⋅105,1≤k≤1091 \leq n \leq 2 \cdot 10^5, 1 \leq k \leq 10^9) —the length of the array aa and the exponent of the operation, respectively.

The second line of each test case contains nn natural numbers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤n1 \leq a_i \leq n) —the array aa.

It is guaranteed that the sum of nn across all test cases does not exceed 2⋅1052 \cdot 10^5.

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

每个测试用例的第一行包含两个整数 nn 和 kk(1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5,1≤k≤1091 \leq k \leq 10^9),分别表示数组 aa 的长度和操作的指数。

每个测试用例的第二行包含 nn 个自然数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤n1 \leq a_i \leq n),即数组 aa。

保证所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output a single line containing an integer — the value of the function f⁡(a,k)\operatorname{f}(a, k) modulo 998 244 353998\,244\,353.

对于每个测试用例,输出一行,包含一个整数——函数 f⁡(a,k)\operatorname{f}(a, k) 对 998 244 353998\,244\,353 取模的结果。

输入输出样例

  • 输入#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,ji,j), the value ω(x)\omega(x) for the product is ω(32)=1\omega(3^2) = 1. There are a total of 66 pairs, and the exponent is 11. The final answer is 66.

Explanation of the second test case example:

In any pair of the second test case, the product of the numbers in the pair equals 11, so the number of primes in it is 00. Therefore, the final answer is also 00.

Explanation of the third test case example:

Consider all pairs (i,ji,j):

  • (1,21,2): the product of the numbers at positions 11 and 22 equals a1⋅a2=1⋅2a_1 \cdot a_2 = 1 \cdot 2, ω(2)=1\omega(2) = 1.
  • (1,31,3): the product of the numbers at positions 11 and 33 equals a1⋅a3=1⋅3a_1 \cdot a_3 = 1 \cdot 3, ω(3)=1\omega(3) = 1.
  • (1,41,4): the product of the numbers at positions 11 and 44 equals a1⋅a4=1⋅4a_1 \cdot a_4 = 1 \cdot 4, ω(22)=1\omega(2^2) = 1.
  • (2,32,3): the product of the numbers at positions 22 and 33 equals a2⋅a3=2⋅3a_2 \cdot a_3 = 2 \cdot 3, ω(2⋅3)=2\omega(2 \cdot 3) = 2.
  • (2,42,4): the product of the numbers at positions 22 and 44 equals a2⋅a4=2⋅4a_2 \cdot a_4 = 2 \cdot 4, ω(23)=1\omega(2^3) = 1.
  • (3,43,4): the product of the numbers at positions 33 and 44 equals a3⋅a4=3⋅4a_3 \cdot a_4 = 3 \cdot 4, ω(3⋅22)=2\omega(3 \cdot 2^2) = 2.

In the answer, the values of ω(x)\omega(x) are raised to the power of 22, so 12+12+12+22+12+22=121^2 + 1^2 + 1^2 + 2^2 + 1^2 + 2^2 = 12.

第一个测试用例示例的解释:

对于任意一对 (i,j)(i,j),其乘积的 ω(x)\omega(x) 值为 ω(32)=1\omega(3^2) = 1。总共有 66 对,且指数为 11。最终答案为 66。

第二个测试用例示例的解释:

在第二个测试用例的所有数对中,每对数的乘积均为 11,因此其中所含的不同质因数个数为 00。故最终答案也为 00。

第三个测试用例示例的解释:

考虑所有数对 (i,j)(i,j):

  • (1,2)(1,2):位置 11 和 22 上的数的乘积为 a1⋅a2=1⋅2a_1 \cdot a_2 = 1 \cdot 2,ω(2)=1\omega(2) = 1。
  • (1,3)(1,3):位置 11 和 33 上的数的乘积为 a1⋅a3=1⋅3a_1 \cdot a_3 = 1 \cdot 3,ω(3)=1\omega(3) = 1。
  • (1,4)(1,4):位置 11 和 44 上的数的乘积为 a1⋅a4=1⋅4a_1 \cdot a_4 = 1 \cdot 4,ω(22)=1\omega(2^2) = 1。
  • (2,3)(2,3):位置 22 和 33 上的数的乘积为 a2⋅a3=2⋅3a_2 \cdot a_3 = 2 \cdot 3,ω(2⋅3)=2\omega(2 \cdot 3) = 2。
  • (2,4)(2,4):位置 22 和 44 上的数的乘积为 a2⋅a4=2⋅4a_2 \cdot a_4 = 2 \cdot 4,ω(23)=1\omega(2^3) = 1。
  • (3,4)(3,4):位置 33 和 44 上的数的乘积为 a3⋅a4=3⋅4a_3 \cdot a_4 = 3 \cdot 4,ω(3⋅22)=2\omega(3 \cdot 2^2) = 2。

在答案中,各 ω(x)\omega(x) 的值需平方后求和,即 12+12+12+22+12+22=121^2 + 1^2 + 1^2 + 2^2 + 1^2 + 2^2 = 12。

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

首页