BestCoder Round #77 (div.2)

so easy

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 288    Accepted Submission(s): 215



思路:多余两个数的集合,在他的所有子集中每个元素都会重复出现偶数次。异或满足结合律。故为0;
一个数时则输出该数;
Problem Description
Given an array with
n
integers, assume f(S) as the result of executing xor operation among all the elements of set S . e.g. if S={1,2,3} then f(S)=0 .

your task is: calculate xor of all f(s) , here sS .
 

Input
This problem has multi test cases. First line contains a single integer T(T20) which represents the number of test cases.
For each test case, the first line contains a single integer number n(1n1,000) that represents the size of the given set. then the following line consists of n different integer numbers indicate elements( 109 ) of the given set.
 

Output
For each test case, print a single integer as the answer.
 

Sample Input
   
   
   
   
1 3 1 2 3
 

Sample Output
   
   
   
   
0 In the sample,$S = \{1, 2, 3\}$, subsets of $S$ are: $\varnothing$, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}
 

Source
BestCoder Round #77 (div.2)
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5654  5653  5649  5648  5647

#include <iostream>
#include<cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <cstring>
using namespace std;

int main()
{
   int t;
   int n;
   int x;
   cin>>t;
   while(t--)
   {
       cin>>n;
       for(int i=0;i<n;i++)
      scanf("%d",&x);
      if(n==1)
      cout<<x<<endl;
      else
        cout<<0<<endl;

   }
    return 0;
}

 

你可能感兴趣的:(BestCoder Round #77 (div.2))