David66666 @ 2024-09-27 15:55:05
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1005],p;
struct node{
int len,val;
}q[1005];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=m;i++)scanf("%d%d",&q[i].len,&q[i].val);
sort(a+1,a+1+n);
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
p=0;
int k=pow(10,q[i].len);
if(a[j]%k==q[i].val){
printf("%d\n",a[j]);
a[j]=-1;
p=1;
break;
}
}
if(p!=1)printf("-1\n");
}
return 0;
}
by David66666 @ 2024-09-27 15:55:56
提交记录
by Partrick_Star @ 2024-09-27 16:15:45
去掉a[j]=-1就好了,我试了下AC了。应该是图书馆的书不是有人用了就没了,一直存在!
by David66666 @ 2024-09-27 16:34:00
@Partrick_Star 已AC
已关