Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products
链接:
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的更多相关文章
- 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. 题解:很显然只有 \( ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Java搭建环境和工具安装详细教程
.一.搭建java运行环境 总体分为两个步骤 1.下载JDK( java dovelop kit 简称 java 开发工具) 首先我们直接下载java开发工具包JDK,转到Oracle官网 下载链接 ...
- axios 发送post请求
目录 方案一 方案二 方案一 在node中使用axios以post的方式发送一张图片给某个server时: let data = fs.createReadStream(__dirname + '/t ...
- python中集合set,字典dict和列表list的区别以及用法
python中set代表集合,list代表列表,dict代表字典 set和dict的区别在于,dict是存储key-value,每一个key都是唯一的,set相对于dict存储的是key,且key是唯 ...
- Comet OJ - Contest #5 迫真图论 (图分块)
大意: 给定无向图, 点$i$点权$b_i$, 边$(x,y,z)$对序列贡献是把$A[b_x \oplus b_y]$加上$z$. 多组询问, 一共三种操作: 1. 修改点权. 2.修改边权. 3. ...
- (十三)使用handler实现登录验证
一.Handel概念 J2EE Web 服务中的Handler技术特点非常像Servlet技术中的Filter.我们知道,在Servlet中,当一个HTTP到达服务端时,往往要经过多个Filter对请 ...
- CCF 201809-1 卖菜
题目: 问题描述 在一条街上有n个卖菜的商店,按1至n的顺序排成一排,这些商店都卖一种蔬菜. 第一天,每个商店都自己定了一个价格.店主们希望自己的菜价和其他商店的一致,第二天,每一家商店都会根据他自己 ...
- mysql 2 修改表
1 修改表名 rename table aaa to bbb; 或者 rename table aaa to bbb; 2 修改字段的数据类型 alter table person modify na ...
- Nginx Too many open files
2019/07/25 08:31:31 [crit] 15929#15929: accept4() failed (24: Too many open files) 2019/07/25 08:31: ...
- Python练习_函数进阶_day10
1. 1.作业 1,写函数,接收n个数字,求这些参数数字的和.(动态传参) 2,读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么? a=10 b=20 def test5(a,b): p ...
- 同步/异步/阻塞/非阻塞/BIO/NIO/AIO
转摘自:https://www.cnblogs.com/lixinjie/p/a-post-about-io-clearly.html 常规的误区 假设有一个展示用户详情的需求,分两步,先调用一个HT ...