wang0728 @ 2022-12-21 20:00:19
#include <bits/stdc++.h>
using namespace std;
int a[1005],b[1005],c[1005];
int cmp(int x,int y)
{
return x>y;
}
int main()
{
int n,q,s,min=10000000,x;
cin>>n>>q;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<q;i++)
{
cin>>c[i]>>b[i];
}
sort(a+0,a+0+n,cmp);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
s=pow(10,c[j]);
x=a[i];
x=x%s;
if(b[i]==x)
{
min=a[i];
}
}
if(min==10000000)
{
cout<<"-1"<<endl;
}
else
{
cout<<min<<endl;
}
min=10000000;
}
return 0;
}
by wenguangxi1 @ 2023-05-22 13:58:20
if(b[i]==x){
if(min>a[i]-b[i]){
min=a[i]-b[i];
minn=a[i]
}
}
else{
cout<<minn<<endl;
}