杭电acm find your present (2)

题目地址:http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=2&problemid=11

使用异或,有个注意的问题就是不能使用cin,实在是太慢了。

c++ 源码:

#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n)==1&&n!=0){
        int res=0,b;
        for(int i=0;i<n;i++){
            scanf("%d",&b);
            res =res^b;
        }
        printf("%d\n",res);
    }
    return 0;
}

 

posted @ 2015-05-23 10:11  湖心北斗  阅读(234)  评论(0编辑  收藏  举报