cyh0228 @ 2023-08-23 21:09:49
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int A=1005;
long long b[A],x[A],e[A],d[A];
int n,q;
int main(){
cin>>n>>q;
for (int i=1;i<=n;i++)
e[i]=1;
for (int i=1;i<=n;i++)
cin>>b[i];
sort(b,b+n+1);
for (int i=1;i<=q;i++){
cin>>d[i]>>x[i];
for (int j=1;j<=d[i];j++)
e[i]*=10;
}
for (int i=1;i<=q;i++){
for (int j=1;j<=n;j++)
if (b[j]%e[i]==x[i]){
cout<<b[j]<<endl;
break;
}
else if (j==n){
cout<<"-1"<<endl;
break;
}
}
return 0;
}
by cyh0228 @ 2023-08-23 21:18:02
@wizard(偷开O2 哥 谢谢·就是那个n的问题 谢谢 小弟感激不尽
by wizard(偷开O2 @ 2023-08-23 21:19:03
@cyh0228 没事:(