题意:

  给一个数组,给你一个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. 寒假答辩作品:Java小游戏

    目录 java入门小游戏[test] 游戏界面 前言 (可直接跳到程序介绍) 前期入门小项目 前期收获 后期自创关卡 后续 java入门小游戏[test] 游戏界面 github地址: https:/ ...

  2. java设计模式学习笔记——里氏替换原则

    oo中的继承性的思考和说明 1.继承包含这样一层含义:父类中凡是已经实现好的方法,实际上是在设定规范和契约,虽然它不强制要求所有的子类必须遵循这些七月,但是如果子类对这些已经实现的方法任意修改,就会对 ...

  3. Explain执行计划与索引优化实践

    一.何为explain执行计划? 使用explain关键字可以模拟优化器执行SQL语句,从而知道MySQL是如何使用索引来处理你的SQL查询语句以及连接表,可以分析查询语句或是结构的性能瓶颈,帮助我们 ...

  4. Vue整合d3.v5.js制作--折线图(line)

    先上效果图(x轴固定为时间轴): 图中出现的悬浮框是鼠标悬停效果 1.环境说明: vue版本:"vue": "^2.5.2" d3版本:"d3&quo ...

  5. IBM x3250m5安装redhat 6.5 加载raid卡驱动

    原文地址:http://www.i5i6.net/post/118.html 1. 下载对应raid卡驱动 for redhat6.5 x64(如本次x3250 m5 c100阵列卡驱动 lsi_dd ...

  6. C语言 getchar

    C语言 getchar getchar是从标准输入设备读取一个char. 案例 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #in ...

  7. linux---基础学习

    学习使用linux 偶然间看到一篇介绍linux的使用,于是看了看,整体看完,虽然看的有些懵✒,但还是坚持看完了基础部分,并做了一些摘要. man页面所属的分类标识 常用的是分类1和分类3 (1).用 ...

  8. windows 2008r2+php5.6.28搭建详细过程

    安装IIS7 1.打开服务器管理器(开始-计算机-右键-管理-也可以打开),添加角色 直接下一步 勾选Web服务器(IIS),下一步,有个注意事项继续下一步(这里我就不截图了) 勾选ASP.NET会弹 ...

  9. Jenkins+robotframework持续集成环境(三)

    构建job并运行 一.配置job 1.在Jenkins首页的左侧菜单栏,点击新建任务,输入一个任务名称,并选择“构建一个自由风格的软件项目”,点击确定进入配置Job页面. 2.在构建处选择Window ...

  10. P1553 数字反转(升级版)(copy(),reverse(),find(),substr(),erase())

    题目描述 给定一个数,请将该数各个位上数字反转得到一个新数. 这次与 NOIp2011 普及组第一题不同的是:这个数可以是小数,分数,百分数,整数.整数反转是将所有数位对调:小数反转是把整数部分的数反 ...