您的位置:首页 > 其它

UVA 10474 Where is the Marble?

2014-08-01 19:07 246 查看
水题

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 10010;
int pos[MAXN],a[MAXN];
int main(){
int n,x,Q,cnt(0);
while(~scanf("%d%d",&n,&Q) && n + Q){

for(int i  = 1;i <= n;i ++) scanf("%d",a + i);
sort(a+1,a+1+n);
memset(pos,0,sizeof pos);
for(int i = 1;i <= n;i ++) pos[a[i]] = pos[a[i]] ? pos[a[i]] : i;
printf("CASE# %d:\n",++cnt);
for(int i = 0;i < Q;i ++){
scanf("%d",&x);
if(pos[x]) printf("%d found at %d\n",x,pos[x]);
else printf("%d not found\n",x);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: