德克萨斯 @ 2020-08-10 09:10:46
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1000],p,q,k[8],minn;
int main()
{
k[1]=10;
for (int i=2;i<=7;i++)
{
k[i]=k[i-1]*10;
}
cin>>n>>m;
for (int i=1;i<=n;i++)
{
cin>>a[i];
}
for (int i=1;i<=m;i++)
{
minn=0x7fffffff;
cin>>p>>q;
for (int j=1;j<=n;j++)
{
if ((a[j]%k[p])==q)
{
minn=min(minn,a[j]);
}
}
if (minn==0x7fffffff)
{
cout<<-1<<endl;
}
else
{
cout<<minn<<endl;
}
}
return 0;
}
by 德克萨斯 @ 2020-08-10 09:12:21
6 8 10这三个不对
by 德克萨斯 @ 2020-08-10 09:12:33
指的测试点
by Yellow_Lemon_Tree @ 2020-08-10 09:24:25
@德克萨斯 a数组建议开到1005,因为1000只是0到999
by 德克萨斯 @ 2020-08-10 09:38:19
@Yellow_Lemon_Tree 我试试
by 德克萨斯 @ 2020-08-10 09:38:59
@Yellow_Lemon_Tree wocao,过了