当前位置:网站首页>C. Fishingprince Plays With Array
C. Fishingprince Plays With Array
2022-06-30 07:42:00 【I would like to have egg yolk and meat dumplings】
I didn't make a big score in the game . The idea is right , No function written , Writing is ugly and long , I don't know what's wrong . I learned the short writing of others .
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int maxn=1e6+5;
int a[maxn],b[maxn];
int n,m;
vector<pair<int,int>> zip(int *a,int n)
{
vector<pair<int,int>>v;
int last=0,num=0;
for(int i=1;i<=n;i++)
{
int cnt=1;
while(a[i]%m==0)
{
cnt*=m;
a[i]/=m;
}
if(a[i]==last) num+=cnt;
else
{
v.push_back({num,last});
num=cnt;
last=a[i];
}
}
v.push_back({num,last});
return v;
}
void solve()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
int k;
cin>>k;
for(int i=1;i<=k;i++)
{
cin>>b[i];
}
if(zip(a,n)==zip(b,k)) puts("YES");
else puts("NO");
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
cin>>t;
while(t--) solve();
}
边栏推荐
- Combinatorial mathematics Chapter 2 Notes
- 回文子串、回文子序列
- Is it safe to open a stock account by mobile phone? What do I need to prepare for opening an account?
- July 30, 2021 [wgs/gwas] - whole genome analysis process (Part I)
- Intersection of two lines
- Armv8 (coretex-a53) debugging based on openocd and ft2232h
- Xiashuo think tank: 28 updates of the planet reported today (including the information of flirting with girls and Han Tuo on Valentine's day)
- 深度学习——嵌入矩阵and学习词嵌入andWord2Vec
- Halcon: read the camera and binary it
- DXP shortcut key
猜你喜欢
Network, network card and IP configuration
Sublime text 3 configuring the C language running environment
At the age of 25, I started to work in the Tiankeng industry with buckets. After going through a lot of hardships to become a programmer, my spring finally came
right four steps of SEIF SLAM
C language implements sequential queue, circular queue and chain queue
Final review -php learning notes 3-php process control statement
Investment and financing analysis report of Supply Chain & logistics industry in 2021
November 19, 2021 [reading notes] a summary of common problems of sneakemake (Part 2)
深度学习——语言模型和序列生成
Combinatorial mathematics Chapter 1 Notes
随机推荐
Basic operation command
HelloWorld
December 4, 2021 [metagenome] - sorting out the progress of metagenome process construction
深度学习——循环神经网络
STM32 register
Disk space, logical volume
Assembly learning register
Investment and financing analysis report of Supply Chain & logistics industry in 2021
C. Fishingprince Plays With Array
2021.11.20 [reading notes] | differential variable splicing events and DTU analysis
Final review -php learning notes 5-php array
期末复习-PHP学习笔记6-字符串处理
Video player (II): video decoding
期末复习-PHP学习笔记2-PHP语言基础
Final review -php learning notes 7-php and web page interaction
2021-10-29 [microbiology] qiime2 sample pretreatment form automation script
Cross compile opencv3.4 download cross compile tool chain and compile (3)
2022 Research Report on China's intelligent fiscal and tax Market: accurate positioning, integration and diversity
MCU essay
November 19, 2021 [reading notes] a summary of common problems of sneakemake (Part 2)