当前位置:网站首页>C. Fishingprince Plays With Array
C. Fishingprince Plays With Array
2022-06-30 07:42:00 【想吃蛋黃肉粽】
賽時沒做出來掉大分。思路是對的,沒寫函數,寫又醜又長,不知道哪裏錯了。學習了一下別人的簡短寫法。
#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();
}边栏推荐
- 2022.01.20 [bug note] | qiime2: an error was encoded while running dada2 in R (return code 1)
- 2022 Research Report on China's intelligent fiscal and tax Market: accurate positioning, integration and diversity
- Cadence physical library lef file syntax learning [continuous update]
- DXP shortcut key
- Proteus catalog component names and Chinese English cross reference table
- How to batch modify packaging for DXP schematic diagram
- 期末复习-PHP学习笔记1
- Final review -php learning notes 11-php-pdo database abstraction layer
- Virtual machine VMware: due to vcruntime140 not found_ 1.dll, unable to continue code execution
- Sublime text 3 configuring the C language running environment
猜你喜欢

Cadence innovus physical implementation series (I) Lab 1 preliminary innovus

Video player (I): process

6月底了,可以开始做准备了,不然这么赚钱的行业就没你的份了

期末复习-PHP学习笔记2-PHP语言基础

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

深度学习——使用词嵌入and词嵌入特征

Final review -php learning notes 1

2022 Research Report on China's intelligent fiscal and tax Market: accurate positioning, integration and diversity

深度学习——目标定位

深度学习——Bounding Box预测
随机推荐
Cadence innovus physical implementation series (I) Lab 1 preliminary innovus
How to batch modify packaging for DXP schematic diagram
DXP shortcut key
Combinatorial mathematics Chapter 1 Notes
STM32 key control LED
November 16, 2021 [reading notes] - macro genome analysis process
24C02
Private method of single test calling object
Video player (I): process
Final review -php learning notes 9-php session control
C language operators
深度学习——目标定位
期末复习-PHP学习笔记4-PHP自定义函数
Record the problem that the system file cannot be modified as an administrator during the development process
Disk space, logical volume
C51 minimum system board infrared remote control LED light on and off
Line fitting (least square method)
2021-10-29 [microbiology] qiime2 sample pretreatment form automation script
November 19, 2021 [reading notes] a summary of common problems of sneakemake (Part 2)
Adjacency matrix representation of weighted undirected graph (implemented in C language)