hdu 4593 Robot

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4593

 

签到题

题意是统计哪个数字出现了两次

只要把每个样例的数字读完以后再输出就没问题

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

const int maxn = 10010;

int cnt[maxn];


int main()
{
    //freopen("in.txt", "r", stdin);

    int n;
    while(scanf("%d", &n) == 1)
    {
        memset(cnt, 0, sizeof(cnt));

        int ans = -1;
        for(int i = 0; i < n+1; i++)
        {
            int tmp;
            scanf("%d", &tmp);
            cnt[tmp]++;
            if(cnt[tmp] >= 2)
                ans = tmp;
        }

        printf("%d\n", ans);
    }

}

 

posted @ 2015-05-26 08:37  地鼠地鼠  阅读(152)  评论(0编辑  收藏  举报