2011年10月24日星期一

周赛某题:异或解法


Problem Description

Give you a sequence of number,in which except for one element,
all number appears twice,your task is to find such a special one.

Input

The first line:N(N<=1000000)
The second line:a1,a2...an
(Use 'scanf' instead of 'cin' to esacpe from TLE,and use 64_bit
integer to hold the input)

Output

Only one number,the special one

Sample Input

   5
   1 1 2 2 3

Sample Output

3






#include
int main()
    int n; __int64 t,m; scanf("%d%I64d",&n,&t);    while(--n){
          scanf("%I64d",&m); t ^= m;
    }
    printf("%I64d\n",t); 
    return 0;
 }



没有评论:

发表评论