HaocoreMix @ 2022-08-21 14:54:55
代码如下
#include <iostream>
#include <algorithm>
using namespace std;
long long n,p,book[100001],temp[100001];
struct read
{
long long number,lenth;
}reader[100001];
int main()
{
cin>>n>>p;
for(int i=1;i<=n;i++)
{
temp[i]=1;
cin>>book[i];
}
for(int i=1;i<=p;i++)
{
cin>>reader[i].lenth>>reader[i].number;
for(int j=1;j<=reader[i].lenth;j++)
temp[i]*=10;
}
sort(book,book+1+n);
for(int i=1;i<=p;i++)
{
for(int j=1;j<=n;j++)
{
if(book[j]%temp[i]==reader[i].number)
{
cout <<book[j]<<endl;
break;
}
else if (j==n)
{
cout<<-1<<endl;
break;
}
}
}
return 0;
}
by jpgzx0301 @ 2023-08-15 09:51:53
输入比所有的都长,所以要把所有的都赋值上