You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
705 B
25 lines
705 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
const int maxn = 10000;
|
|
|
|
int main() {
|
|
int n, q, x, a[maxn], kase = 0;
|
|
while (scanf("%d%d", &n, &q) == 2 && n) {
|
|
printf("CASE# %d:\n", ++kase);
|
|
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
|
|
//排序
|
|
sort(a, a + n);
|
|
//从后向前找
|
|
while (q--) {
|
|
scanf("%d", &x);
|
|
//lower_bound:
|
|
//https://blog.csdn.net/qq_40160605/article/details/80150252
|
|
int p = lower_bound(a, a + n, x) - a; //在已排序数组a中寻找x
|
|
if (a[p] == x) printf("%d found at %d\n", x, p + 1);
|
|
else printf("%d not found\n", x);
|
|
}
|
|
}
|
|
return 0;
|
|
} |