UVA 10474 Where is the Marble?
2014-08-01 19:07
190 查看
水题
#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; }
相关文章推荐
- UVa 10474 Where is the Marble? (二分查找&equal_range()的使用)
- UVA 10474 Where is the Marble?
- uva 10474 Where is the Marble? 计数排序
- UVA 10474 - Where is the Marble?
- uva 10474 Where is the Marble?
- UVA 10474 Where is the Marble?
- UVa 10474 - Where is the Marble
- Uva 10474 Where is the Marble?
- uva 10474 Where is the Marble?
- uva-10474 - Where is the Marble?
- UVa10474 Where is the Marble?
- UVA10474 - Where is the Marble?
- UVa 10474 - Where is the Marble?
- UVa - 10474 - Where is the Marble?
- uva 10474 - Where is the Marble?
- UVA 10474 - Where is the Marble?
- UVa 10474 Where is the Marble?
- UVa 10474 - Where is the Marble?
- uva 10474 Where is the Marble? 计数排序
- UVa 10474 - Where is the Marble?