链接:

https://codeforces.com/contest/1247/problem/D

题意:

You are given n positive integers a1,…,an, and an integer k≥2. Count the number of pairs i,j such that 1≤i<j≤n, and there exists an integer x such that ai⋅aj=xk.

思路:

对每个数质数拆分,记录质数的指数modk的值,map记录vector神仙操作。。。

代码:

//#include <iostream>
//#include <fstream>
//#include <process.h>
//#include "ch08/ch08Func.cpp"
#include <bits/stdc++.h>
typedef long long LL;
using namespace std; int n, k; map<vector<pair<int, int>>, int> Mp; int main()
{
ios::sync_with_stdio(false);
LL res = 0;
int val;
cin >> n >> k;
for (int i = 1;i <= n;i++)
{
vector<pair<int, int> > v1, v2;
cin >> val;
for (int j = 2;j*j <= val;j++)
{
int _ = 0;
if (val%j == 0)
{
while (val%j == 0)
{
val /= j;
_++;
}
}
if (_%k)
v1.emplace_back(j, _%k);
}
if (val > 1)
v1.emplace_back(val, 1);
for (auto v: v1)
v2.emplace_back(v.first, k-v.second);
res += Mp[v2];
Mp[v1]++;
}
cout << res << endl; return 0;
}

Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products的更多相关文章

  1. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

  2. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) C. p-binary

    链接: https://codeforces.com/contest/1247/problem/C 题意: Vasya will fancy any number as long as it is a ...

  3. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) B2. TV Subscriptions (Hard Version)

    链接: https://codeforces.com/contest/1247/problem/B2 题意: The only difference between easy and hard ver ...

  4. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things

    链接: https://codeforces.com/contest/1247/problem/A 题意: Kolya is very absent-minded. Today his math te ...

  5. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) F. Tree Factory 构造题

    F. Tree Factory Bytelandian Tree Factory produces trees for all kinds of industrial applications. Yo ...

  6. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) E. Rock Is Push dp

    E. Rock Is Push You are at the top left cell (1,1) of an n×m labyrinth. Your goal is to get to the b ...

  7. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) B. TV Subscriptions 尺取法

    B2. TV Subscriptions (Hard Version) The only difference between easy and hard versions is constraint ...

  8. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things 水题

    A. Forgetting Things Kolya is very absent-minded. Today his math teacher asked him to solve a simple ...

  9. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products 数学 暴力

    D. Power Products You are given n positive integers a1,-,an, and an integer k≥2. Count the number of ...

随机推荐

  1. SQL-锁-事物级别

    一.锁 锁是一种安全机制,控制并发操作,防止用户读取其他用户正在更改的数据,或者多用户同时修改一个数据,从而保证事物的完整性和数据库的一致性.SQLserver 会自动强制执行锁,但是用户可以通过对锁 ...

  2. Feign【首次请求失败】

    当feign和ribbon整合hystrix之后,可能会出现首次调用失败的问题,出现原因分析如下: hystrix默认的超时时间是1秒,如果接口请求响应超过这个时间,将会执行fallback,spri ...

  3. 安卓版 WPS 使用电脑字体、安卓版 WPS 添加字体、安卓 WPS 无法显示文档真实字体(24)

    1. 前言 安卓版WPS默认只有那么几种字体,查看电脑的Office文档无法显示文档的真实字体.想要用更多的字体需要开会员,这里提供免费方案. 2. 操作步骤 1.先在手机中打开一个要查看的文档: 2 ...

  4. BinaryTree(HDU-5573)【思维/构造】

    题目链接:https://vjudge.net/problem/HDU-5573 题意:一棵二叉树,编号代表对应节点的取值,可以走k步,每次走的层数递增,问能够达到N的方案. 思路:首先看一下数据范围 ...

  5. double check

    http://www.cnblogs.com/limingluzhu/p/5156659.html http://blog.csdn.net/chenchaofuck1/article/details ...

  6. SAS学习笔记5 字符截取语句(index、compress、substr、scan函数)

    index:返回一个字符串中,某个特定字符或字符串的位置,找不到时返回0 compress:从一个字符串移除特定的字符 substr函数 字符替换与提取字符 substr(s, p, n)从变量s的第 ...

  7. array_chunk — 将一个数组分割成多个

    说明 array_chunk ( array $array , int $size [, bool $preserve_keys = false ] ) : array 将一个数组分割成多个数组,其中 ...

  8. 去除空格函数trim

    实际查询中,经常存在多个tables,需要统一查询比如segments总大小或者索引或者主键等,我们得到大量的tables表名称,但是SQL查询,每次需要手工添加双引号,去除空格很麻烦. 可以通过文本 ...

  9. Asp.Net Core 轻松学系列-3项目目录和文件作用介绍

    目录 前言 结语 前言     上一章介绍了 Asp.Net Core 的前世今生,并创建了一个控制台项目编译并运行成功,本章的内容介绍 .NETCore 的各种常用命令.Asp.Net Core M ...

  10. vue-cli || webpack 打包的时候css里面写的背景图片的路径出错问题

    .bg width 100% position fixed left 0 top 0 height 100vh z-index -1 background url('~@/assets/imgs/bg ...