题意:

  给一个数组,给你一个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. tensorflow开发环境版本组合

    记录下各模块的版本 tensorflow 1.15.0       print tf.__version__ cuda 10.0.130            nvcc -v cudnn 7.6.4  ...

  2. 远程服务器返回错误:(414)Request-URI Too Large

    近期因为疫情原因,一直是在家办公了,也导致了和同事对接接口上出现了很多小问题,这也从侧面反映出我个人对项目的设计不全面. 上面是对接接口时产生的一个问题:远程服务器返回错误:(414)Request- ...

  3. pikachu-SQL注入漏洞

    一.SQL Inject 漏洞原理概述 1.1 什么是数据库注入漏洞     数据库注入漏洞,主要是开发人员在构建代码的时候,没有对用户输入的值的边界进行安全的考虑,导致攻击者可以通过合法的输入点提交 ...

  4. 【01】HTML_day01_03-HTML常用标签

    typora-copy-images-to: media 第01阶段.前端基础.HTML常用标签 学习目标 理解: 相对路径三种形式 应用 排版标签 文本格式化标签 图像标签 链接 相对路径,绝对路径 ...

  5. AI Web 2.0

    kali: 192.168.0.103 目标机:192.168.0.105 0X01 扫描端口和目录 a)扫描端口 开启了80和22端口 b)扫描目录 看到两个敏感字样的目录 尝试访问/webadmi ...

  6. <packaging>pom</packaging>是什么意思

    <packaging>pom</packaging>是什么意思? 答: 以下配置<packaging>pom</packaging>的意思是使用mave ...

  7. BUUCTF 部分wp

    目录 Buuctf crypto 0x01传感器 提示是曼联,猜测为曼彻斯特密码 wp:https://www.xmsec.cc/manchester-encode/ cipher: 55555555 ...

  8. postman请求(请求方式、请求url、请求参数、参数类型、请求头)

    请求方式:get 请求地址: 请求参数:url与参数用?间隔,多个参数用&间隔 请求方式:post 请求地址: 请求参数: 请求参数格式:前面两种是key-value.第三种可以选择json/ ...

  9. VSCode(主进程)

    Overview(总览) SETUP(设定) Overview(总览) Linux(略) macOS(略) Windows 使用WSL,您可以在Windows上安装和运行Linux发行版.这使您能够在 ...

  10. job无法自动运行基于ABP后台服务 - 后台作业和后台工人

    原因: 后台作业和后台工人仅在你的应用程序运行的时候才工作.如果web应用长时间没有被请求执行,Asp.Net应用默认是关闭的 解决方案: 应用程序池(Application Pool),Proces ...