当前位置:网站首页>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();
}边栏推荐
- 期末複習-PHP學習筆記3-PHP流程控制語句
- Binary tree related operations (based on recursion, implemented in C language)
- 深度学习——目标定位
- Cross compile opencv3.4 download cross compile tool chain and compile (3)
- December 4, 2021 - Introduction to macro genome analysis process tools
- Program acceleration
- C language implements sequential queue, circular queue and chain queue
- 2021 private equity fund market report (62 pages)
- Final review -php learning notes 8-mysql database
- Installation software operation manual (continuous update)
猜你喜欢

期末复习-PHP学习笔记6-字符串处理

Efga design open source framework openlane series (I) development environment construction

Combinatorial mathematics Chapter 2 Notes

深度学习——语言模型和序列生成

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

Record the problem that the system file cannot be modified as an administrator during the development process

Dynamic memory management

Final review -php learning notes 9-php session control
![2022.01.20 [bug note] | qiime2: an error was encoded while running dada2 in R (return code 1)](/img/c0/2c5efdbefd6f9b591541b1204c3ea2.jpg)
2022.01.20 [bug note] | qiime2: an error was encoded while running dada2 in R (return code 1)

深度学习——目标定位
随机推荐
Final review -php learning notes 9-php session control
Adjacency matrix representation of weighted undirected graph (implemented in C language)
342 maps covering exquisite knowledge, one of which is classic and pasted on the wall
July 30, 2021 [wgs/gwas] - whole genome analysis process (Part I)
Application of stack -- using stack to realize bracket matching (C language implementation)
想转行,却又不知道干什么?此文写给正在迷茫的你
Introduction notes to pytorch deep learning (11) neural network pooling layer
C language implementation of chain stack (without leading node)
Dynamic memory management
深度学习——GRU单元
STM32 infrared communication 2
Solve the linear equation of a specified point and a specified direction
深度学习——BRNN和DRNN
C language operators
Assembly learning register
Distance from point to line
December 19, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5 advanced database search)
冰冰学习笔记:快速排序
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)
C language implementation sequence stack