CF1225D.Power Products

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given nn positive integers a1,…,ana_1, \ldots, a_n, and an integer k≥2k \geq 2. Count the number of pairs i,ji, j such that 1≤i<j≤n1 \leq i \lt j \leq n, and there exists an integer xx such that ai⋅aj=xka_i \cdot a_j = x^k.

给你 nn 个正整数 a1,…,ana_1, \ldots, a_n 和一个整数 k≥2k \geq 2。请统计满足 1≤i<j≤n1 \leq i \lt j \leq n 且存在整数 xx 使得 ai⋅aj=xka_i \cdot a_j = x^k 的数对 (i,j)(i, j) 的个数。

输入格式

The first line contains two integers nn and kk (2≤n≤1052 \leq n \leq 10^5, 2≤k≤1002 \leq k \leq 100).

The second line contains nn integers a1,…,ana_1, \ldots, a_n (1≤ai≤1051 \leq a_i \leq 10^5).

第一行包含两个整数 nn 和 kk(2≤n≤1052 \leq n \leq 10^5,2≤k≤1002 \leq k \leq 100)。

第二行包含 nn 个整数 a1,…,ana_1, \ldots, a_n(1≤ai≤1051 \leq a_i \leq 10^5)。

输出格式

Print a single integer — the number of suitable pairs.

输出一个整数——满足条件的数对个数。

输入输出样例

  • 输入#1

    6 3
    1 3 9 8 24 1

    输出#1

    5

说明/提示

In the sample case, the suitable pairs are:

  • a1⋅a4=8=23a_1 \cdot a_4 = 8 = 2^3;
  • a1⋅a6=1=13a_1 \cdot a_6 = 1 = 1^3;
  • a2⋅a3=27=33a_2 \cdot a_3 = 27 = 3^3;
  • a3⋅a5=216=63a_3 \cdot a_5 = 216 = 6^3;
  • a4⋅a6=8=23a_4 \cdot a_6 = 8 = 2^3.

在样例中,符合条件的数对有:

  • a1⋅a4=8=23a_1 \cdot a_4 = 8 = 2^3;
  • a1⋅a6=1=13a_1 \cdot a_6 = 1 = 1^3;
  • a2⋅a3=27=33a_2 \cdot a_3 = 27 = 3^3;
  • a3⋅a5=216=63a_3 \cdot a_5 = 216 = 6^3;
  • a4⋅a6=8=23a_4 \cdot a_6 = 8 = 2^3。

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

首页