当前位置:网站首页>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();
}边栏推荐
- 期末複習-PHP學習筆記6-字符串處理
- Deloitte: investment management industry outlook in 2022
- Line fitting (least square method)
- 冰冰学习笔记:快速排序
- Inversion Lemma
- 期末复习-PHP学习笔记8-mysql数据库
- November 16, 2021 [reading notes] - macro genome analysis process
- 期末复习-PHP学习笔记5-PHP数组
- Network security and data in 2021: collection of new compliance review articles (215 pages)
- C language - student achievement management system
猜你喜欢

Examen final - notes d'apprentissage PHP 3 - Déclaration de contrôle du processus PHP
![2021.11.20 [reading notes] | differential variable splicing events and DTU analysis](/img/02/6971454e51c015990b5b60b357ee1d.jpg)
2021.11.20 [reading notes] | differential variable splicing events and DTU analysis

Video player (II): video decoding

Introduction notes to pytorch deep learning (XII) neural network - nonlinear activation

Disk space, logical volume

Processes, jobs, and services

Final review -php learning notes 8-mysql database

Multi whale capital: report on China's education intelligent hardware industry in 2022
![November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)](/img/0d/77953ffa9f45a5acc16f02bf33293b.jpg)
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)

深度学习——词汇表征
随机推荐
深度学习——卷积的滑动窗口实现
Analysis of cross clock transmission in tinyriscv
November 21, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5 advanced database search)
Armv8 (coretex-a53) debugging based on openocd and ft2232h
C language implements sequential queue, circular queue and chain queue
Xiashuo think tank: 125 planet updates reported today (packed with 101 meta universe collections)
Final review -php learning notes 7-php and web page interaction
Halcon: read the camera and binary it
STM32 register
期末复习-PHP学习笔记8-mysql数据库
November 19, 2021 [reading notes] a summary of common problems of sneakemake (Part 2)
Video player (I): process
期末复习-PHP学习笔记9-PHP会话控制
Wangbohua: development situation and challenges of photovoltaic industry
Directory of software
Calculate Euler angle according to rotation matrix R yaw, pitch, roll source code
Final review -php learning notes 1
Experiment 1: comprehensive experiment [process on]
Binary tree related operations (based on recursion, implemented in C language)
25岁,从天坑行业提桶跑路,在经历千辛万苦转行程序员,属于我的春天终于来了