当前位置:网站首页>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();
}边栏推荐
- Digital white paper on total cost management in chain operation industry
- November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)
- Permutation and combination of probability
- C language implementation of chain stack (without leading node)
- 2022 retail industry strategy: three strategies for consumer goods gold digging (in depth)
- Account command and account authority
- Cross compile opencv3.4 download cross compile tool chain and compile (3)
- 期末复习-PHP学习笔记4-PHP自定义函数
- C. Fishingprince Plays With Array
- 深度学习——残差网络ResNets
猜你喜欢

24C02

C language - student achievement management system

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

Common sorting methods

Investment and financing analysis report of Supply Chain & logistics industry in 2021

为什么大学毕业了还不知道干什么?

Combinatorial mathematics Chapter 2 Notes

Deloitte: investment management industry outlook in 2022
![December 4, 2021 [metagenome] - sorting out the progress of metagenome process construction](/img/03/eb6e6092922cf42c2c9866e7bb504d.jpg)
December 4, 2021 [metagenome] - sorting out the progress of metagenome process construction

C language implements sequential queue, circular queue and chain queue
随机推荐
Adjacency matrix representation of weighted undirected graph (implemented in C language)
Video player (I): process
Common sorting methods
Wangbohua: development situation and challenges of photovoltaic industry
Raspberry pie 4B Getting Started Guide
Log service management
Intersection of two lines
Lodash filter collection using array of values
Projection point of point on line
Basic theory of four elements and its application
期末复习-PHP学习笔记11-PHP-PDO数据库抽象层.
Lexicographic order -- full arrangement in bell sound
Spring Festival inventory of Internet giants in 2022
Cadence innovus physical implementation series (I) Lab 1 preliminary innovus
Final review -php learning notes 3-php process control statement
String application -- string violent matching (implemented in C language)
Label the picture below the uniapp picture
Combinatorial mathematics Chapter 1 Notes
Analysys analysis: online audio content consumption market analysis 2022
Efga design open source framework openlane series (I) development environment construction