题意:

  给一个数组,给你一个k,找出两个数字的积可以变成xk的数对对数

解析:

  当且仅当,两个数进行质因子分解后每个因子的个数都是k的倍数个就说明这是满足条件的一对,可以让每个因子个数%k用map找对应的数。

代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <map> using namespace std; typedef long long LL; const int mod=1e9+;
const int maxn=1e5+; int n,k; struct node{
int x,num;
node(){}
node(int _x,int _num):x(_x),num(_num){}
bool operator<(const node &s)const{
if(x!=s.x)return x<s.x;
else return num<s.num;
}
}; vector<node>nodes;
map<vector<node>,int>mp; void f(int x){
int o=;
for(int i=;i<=x/i;i++){
if(x%i==){
int num=;
while(x%i==){
num++;
x/=i;
}
if(num%k!=){
o=;
nodes.push_back(node(i,num%k));
}
}
}
if(x!=)nodes.push_back(node(x,));
if((int)nodes.size()==&&(o==||x==)){
//nodes.push_back(node(x,1));
}
} int main(){
scanf("%d%d",&n,&k);
long long num=;
for(int i=;i<n;i++){
int x;
scanf("%d",&x);
nodes.clear();
f(x);
for(int i=;i<(int)nodes.size();i++){
nodes[i].num=k-nodes[i].num;
}
if(mp[nodes]!=){
num+=mp[nodes];
}
for(int i=;i<(int)nodes.size();i++){
nodes[i].num=k-nodes[i].num;
//printf("%d %d\n",nodes[i].x,nodes[i].num);
}
mp[nodes]++;
//printf("%d %lld\n",i,num);
}
printf("%lld\n",num);
return ;
}

Codeforces Round #596 (Div. 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) D. Power Products 数学 暴力

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

  3. 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 ...

  4. 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 ...

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

    C. p-binary Vasya will fancy any number as long as it is an integer power of two. Petya, on the othe ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Go1.14发布了,快来围观新的特性啦

    如期而至,Go1.14发布了,和往常一样,该版本保留了Go 1兼容性的承若,这个版本的大部分更新在工具链 .运行时库的性能提升方面,总的来说,还是在已有的基础上不断优化提成,大家期待的泛型还没有到来, ...

  2. .net List回收

    转 static void Main(string[] args) { List<int> list = new List<int>(); for (int i = 0; i ...

  3. UML之二、建模元素(1)

    本章介绍UML建模元素 1:Stereotype-也被称为类型.构造型 UML里的元素扩展,简单来说其功能就是在已有的类型上添加一些标记,类似于打个戳,从而生成新的东西. 简单的说加一句话来更加清楚准 ...

  4. 链接github

    引用https://www.cnblogs.com/u-1596086/p/11588957.html 第一步:登录git创建项目 右上角头像按钮,点击your repositories 接着绿色按钮 ...

  5. Flink中逻辑计划和物理计划的概念划分和对应关系

    逻辑计划 logicGraph或者jobGraph,其端点为operator,edge为数据流向. operator往往代表一个函数. 同一个分区内的具有连续上下游关系的函数组成operator-ch ...

  6. 基于Jupyter Notebooks的C# .NET Interactive安装与使用

    .NET Interactive发布预览版了,可以像Python那样用jupyter notebooks来编辑C#代码.具体可以在GitHub上查看dotnet/interactive项目. 安装步骤 ...

  7. python爬虫步骤 (新手备学 )爬虫编程。

    Python爬虫是用Python编程语言实现的网络爬虫,主要用于网络数据的抓取和处理,相比于其他语言,Python是一门非常适合开发网络爬虫的编程语言,大量内置包,可以C Python爬虫可以做的事情 ...

  8. 使用TensorRT对人脸检测网络MTCNN进行加速

    前言 最近在做人脸比对的工作,需要用到人脸关键点检测的算法,比较成熟和通用的一种算法是 MTCNN,可以同时进行人脸框选和关键点检测,对于每张脸输出 5 个关键点,可以用来进行人脸对齐. 问题 刚开始 ...

  9. jmeter-json提取器提取的内容含”引号

    这时如果直接赋值会报错  解决方法: 1.用vars.get("Object")提取变量的值 2.用代码提取,最后把提取到的Object或Array转为String

  10. 基于JavaSwing开发银行信用卡管理系统

    开发环境: Windows操作系统开发工具: MyEclipse10/Eclipse+Jdk+Mysql数据库 运行效果图 源码及原文链接:https://javadao.xyz/forum.php? ...