当前位置:网站首页>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();
}
边栏推荐
- Solve the linear equation of a specified point and a specified direction
- 架构实战营模块 5 作业
- 深度学习——语言模型和序列生成
- 深度学习——目标定位
- November 19, 2021 [reading notes] a summary of common problems of sneakemake (Part 2)
- Calculate Euler angle according to rotation matrix R yaw, pitch, roll source code
- Label the picture below the uniapp picture
- Wangbohua: development situation and challenges of photovoltaic industry
- Processes, jobs, and services
- 深度学习——GRU单元
猜你喜欢
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Section 5 of Chapter 5 uses a comparison tool similar to blast to quickly search genomic DNA)
December 19, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5 advanced database search)
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
November 21, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5 advanced database search)
Parameter calculation of deep learning convolution neural network
Global digital industry strategy and policy observation in 2021 (China Academy of ICT)
Commands and permissions for directories and files
期末複習-PHP學習筆記6-字符串處理
Final review -php learning notes 9-php session control
Final review -php learning notes 4-php custom functions
随机推荐
架构实战营模块 5 作业
November 19, 2021 [reading notes] a summary of common problems of sneakemake (Part 2)
Virtual machine VMware: due to vcruntime140 not found_ 1.dll, unable to continue code execution
深度学习——序列模型and数学符号
ACM. HJ48 从单向链表中删除指定值的节点 ●●
Efga design open source framework fabulous series (I) establishment of development environment
Raspberry pie 4B Getting Started Guide
C language - student achievement management system
Investment and financing analysis report of Supply Chain & logistics industry in 2021
National technology n32g45x series about timer timing cycle calculation
Next initializesecuritycontext failed: unknown error (0x80092012) - the revocation function cannot check whether the certificate is revoked.
深度学习——词汇表征
C51 minimum system board infrared remote control LED light on and off
深度学习——特征点检测和目标检测
Directory of software
Tencent and Fudan University "2021-2022 yuan universe report" with 102 yuan universe collections
STM32 key control LED
Combinatorial mathematics Chapter 1 Notes
期末复习-PHP学习笔记4-PHP自定义函数
Spring Festival inventory of Internet giants in 2022