UVa 10474 - Where is the Marble?

来源:互联网 发布:河北网络公益广告大赛 编辑:程序博客网 时间:2024/04/30 17:15
#include <iostream>#include <cstdio>#include <cstring>int a[10010];using namespace std;int main(){    #ifndef ONLINE_JUDGE    freopen("in.txt", "r", stdin);    #endif    int n, q;    int num;    int test_case = 0;    while(scanf("%d%d", &n, &q) == 2) {        if(n==0 && q==0) break;        memset(a, 0, sizeof(a));        while(n--) {            scanf("%d", &num);            a[num]++;        }        int pre=1, temp;        for(int i=1; i<=10000; i++) {            if(a[i] > 0) {                temp = pre + a[i];                a[i] = pre;                pre = temp;            }        }        printf("CASE# %d:\n", ++test_case);        while(q--) {            scanf("%d", &num);            if(a[num] <= 0) printf("%d not found\n", num);            else printf("%d found at %d\n", num, a[num]);        }    }    return 0;}