当前位置:网站首页>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();
}边栏推荐
- 2021-10-29 [microbiology] qiime2 sample pretreatment form automation script
- Private method of single test calling object
- 期末复习-PHP学习笔记7-PHP与web页面交互
- Given a fixed point and a straight line, find the normal equation of the straight line passing through the point
- Graphic explanation pads update PCB design basic operation
- HelloWorld
- 深度学习——GRU单元
- February 14, 2022 [reading notes] - life science based on deep learning Chapter 2 Introduction to deep learning (Part 1)
- 期末复习-PHP学习笔记8-mysql数据库
- Log service management
猜你喜欢

Final review -php learning notes 9-php session control

Parameter calculation of deep learning convolution neural network

期末复习-PHP学习笔记7-PHP与web页面交互

Digital white paper on total cost management in chain operation industry

Tencent and Fudan University "2021-2022 yuan universe report" with 102 yuan universe collections

Final review -php learning notes 4-php custom functions

Use of nested loops and output instances

深度学习——序列模型and数学符号

Combinatorial mathematics Chapter 2 Notes

Binary tree related operations (based on recursion, implemented in C language)
随机推荐
Log service management
Tencent and Fudan University "2021-2022 yuan universe report" with 102 yuan universe collections
Introduction notes to pytorch deep learning (11) neural network pooling layer
Inversion Lemma
Processes, jobs, and services
Halcon: read the camera and binary it
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)
Parameter calculation of deep learning convolution neural network
Global digital industry strategy and policy observation in 2021 (China Academy of ICT)
期末複習-PHP學習筆記6-字符串處理
STM32 register on LED
2021-10-29 [microbiology] a complete set of 16s/its analysis process based on qiime2 tool (Part I)
right four steps of SEIF SLAM
Experiment 1: comprehensive experiment [process on]
Tue Jun 28 2022 15:30:29 GMT+0800 (中国标准时间) 日期格式化
C51 minimum system board infrared remote control LED light on and off
342 maps covering exquisite knowledge, one of which is classic and pasted on the wall
Ad\dxp how to solve the problem of not knowing the schematic Library
DXP software uses shortcut keys
为什么大学毕业了还不知道干什么?