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 ...
随机推荐
- c++学习---vector
vector存放类型不同,{}有些区别-: vector的size的返回类型: push_back的使用: 要防止缓冲区溢出,使用范围for语句:
- Django-redis配置cache和session
CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", &q ...
- poj 3253 哈夫曼贪心
http://poj.org/problem?id=3253 题意: FJ需要修补牧场的围栏,他需要 N 块长度为 Li 的木头(N planks of woods).开始时,FJ只有一块无限长的木板 ...
- [Vue]vue中路由重定向redirect
1.重定向的地址不需要接收参数 const routes = [ { path: '/', redirect: '/index'}, { path: '/index', component: inde ...
- 【web】使用ionic搭建移动端项目 icon-radio 标签在ios下全部选中的问题
这块css 导致的问题 .disable-pointer-events { pointer-events: none; }
- Centos 在VM中设置静态ip
cd /etc/sysconfig/network-scripts 然后代开第一个文件 一般是ifcfg-ens331)开始配置原来是这样的 修改/etc/sysconfig/network # Cr ...
- row_number() over()函数基本用法
简单的说row_number()从1开始,为每一条分组记录返回一个数字,这里的ROW_NUMBER() OVER (ORDER BY xlh DESC) 是先把xlh列降序,再为降序以后的没条xlh记 ...
- 简单注册表单--HTML练手项目3【Table】
[本文为原创,转载请注明出处] 技术[HTML] 布局[Table] 步骤1 划分table布局 步骤2 填充内容 文本框+密码框+单选框+复选框+多行文本域+按钮 <input> ...
- form-create教程:移除默认提交按钮
本文将介绍form-create如何修改,隐藏默认提交按钮 form-create 是一个可以通过 JSON 生成具有动态渲染.数据收集.验证和提交功能的表单生成器.并且支持生成任何 Vue 组件.结 ...
- flex 布局方式
开始啦 1. flex-direction 有关主轴的对齐方式 column 自上到下 row 自左到右 -->默认值 row-reverse 自右到左 column-reverse 自下到上 ...