链接:

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. [转帖]MMU内存管理单元

    MMU内存管理单元 https://www.cnblogs.com/alantu2018/p/9002309.html 之前对这一块一直不理解 最近学习了点 CPU time slice 以及 con ...

  2. 1234: 约瑟夫问题-输出最后的编号(Java)

    WUSTOJ 1234: 约瑟夫问题-输出最后的编号 参考资料 约瑟夫问题--百度百科 Description n个人围成一圈,依次从1至n编号.从编号为1的人开始1至k报数,凡报数为k的人退出圈子, ...

  3. 四、poll()、select()和epoll()

    在用户程序中,poll()和select()系统调用用于对设备进行无阻塞访问.poll()和select()最终会调用设备驱动中的poll()函数,在我所使用的Linux内核中,还有扩展的poll() ...

  4. JS 05 json

    1.下载jar包: https://www.github.com/alibaba/fastjson/releases https://www.mvnrepository.com/artifact/co ...

  5. MacBook使用HHKB键盘设置

    问题: macbook上使用hhkb的时候,很纠结档位4要不要开,开启4号DIP开关后,虽然会使HHKB键盘上减少一个“◇(Win键)”键,但是会在键盘左侧多出一个“FN”键.多出来的左“FN”键,不 ...

  6. (一)shiro简介和用户登录demo及角色管理

    一.shiro简介 Apache Shiro是Java的一个安全框架.Shiro可以非常容易的开发出足够好的应用,其不仅可以用在JavaSE环境,也可以用在JavaEE环境.Shiro可以帮助我们完成 ...

  7. 手机如何修改host文件

    常常在想本地开发的时候使用pc端测试移动端,由于有安全域名限制,因此在本地修改了机器的host.将域名映射到本地局域网.这个做法是很正常的也很常见.但是现在新的需求是我需要在手机上也能够正常测试啊!怎 ...

  8. Entity framework 意外删除了表,如何在不影响其它表的情况下恢复回来

    关于EntityFramework数据迁移原理 查询数据库的表"__MigrationHistory",遍历代码库的Migrations文件夹下的所有文件,如果文件不在__Migr ...

  9. 解析Illumina+PacBio组装策略

    解析Illumina+PacBio组装策略 (2016-12-08 13:21:58) 转载▼     基于Illumina和PacBio平台的“二加三”组装策略,巧妙的融合了PacBio平台超长读长 ...

  10. JSP开发 路径问题汇总

    //第一种 jsp 表达式 <%=request.getContextPath %> 获取到 web项目名的绝对路径 <!--使用绝对路径的方式引入CSS文件--> <l ...