UVA 10747 大理石在哪?

/*
UVA10474
*/ 

#include 
#include 
using namespace std;

const int maxn = 10000;

int main(){
	int n, q;
	int id = 1;
	int a[maxn];
	while(scanf("%d %d",&n, &q)==2 && n && q){
		printf("CASE# %d:\n", id++);
		for(int i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
		sort(a, a+n);
		int x, pos;
		while(q--){
			scanf("%d",&x);
			pos = lower_bound(a, a+n, x)-a;
			if(a[pos] == x)
				printf("%d found at %d\n", x, pos+1);
			else
				printf("%d not found\n", x); 
		}
	}
	return 0;
}

 

你可能感兴趣的:(算法竞赛学习)