取名不要太长,像我这样刚刚好 • 9个月前
using namespace std;
int main() {
int n, q, min, flage, m, b, c;
int a[1010];
scanf("%d%d", &n, &q);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
while (q--) {
scanf("%d%d", &m, &b);
c = pow(10, m);
min = numeric_limits<int>::max();
flage = 0;
for (int i = 0; i < n; i++) {
int d = a[i] % c;
if (d == b) {
flage = 1;
if (a[i] < min) {
min = a[i];
}
}
}
if (flage)
cout << min << endl;
else
cout << "-1" << endl;
}
return 0;
}
评论:
请先登录,才能进行评论