Tanky WooRSS

南航 OJ 1184 迷失的邮票

25 May 2010
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

今天群里以朋友问了我一道题,是南航的OJ,AC了顺便放上来。

题目地址:

http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1184

 #include 

long stamp[1000000];
long x;

int main()
{
    long n;
    int i;
    long max_x = 0;
    scanf("%ld", &n;);
    for(i = 0; i < n-2; i++)
    {
        scanf("%ld", &x;);
        if(max_x < x)
            max_x = x;
        if(stamp[x] == 0)
            stamp[x] = 1;
        else
            stamp[x] = 0;
    }
    int cnt = 0;
    for(i = 0; i <= max_x; i++)
    {
        if(stamp[i] && cnt == 0)
        {
            printf("%d ", i);
            cnt++;
        }
        else if(stamp[i] && cnt == 1)   //第二个数后面还不能有空格,否则“描述错误”
        {
            printf("%d\n", i);
            cnt++;
        }
        if(cnt == 2)
            break;
    }
    return 0;
}