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 $s \subseteq S$.Input
This problem has multi test cases. First line contains a single integer $T(T\leq 20)$ which represents the number of test cases.
For each test case, the first line contains a single integer number $n(1\leq n \leq 1,000)$ that represents the size of the given set. then the following line consists of $n$ different integer numbers indicate elements($\leq 10^9$) of the given set.Output
For each test case, print a single integer as the answer.Sample Input
1 3 1 2 3Sample 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}
a^b^a=b
1 /* 2 By:OhYee 3 Github:OhYee 4 Email:oyohyee@oyohyee.com 5 Blog:http://www.cnblogs.com/ohyee/ 6 7 かしこいかわいい? 8 エリーチカ! 9 要写出来Хорошо的代码哦~ 10 */ 11 #include <cstdio> 12 #include <algorithm> 13 #include <cstring> 14 #include <cmath> 15 #include <string> 16 #include <iostream> 17 #include <vector> 18 #include <list> 19 #include <queue> 20 #include <stack> 21 using namespace std; 22 23 //DEBUG MODE 24 #define debug 0 25 26 //循环 27 #define REP(n) for(int o=0;o<n;o++) 28 29 const int maxn = 10000; 30 int n, m; 31 int Map[maxn][maxn]; 32 33 void Do() { 34 int n; 35 scanf("%d", &n); 36 int temp, ans; 37 if (n==1) { 38 REP(n) { 39 if (o == 0) 40 scanf("%d", &ans); 41 42 else 43 scanf("%*d", &temp); 44 } 45 } 46 else { 47 REP(n) 48 scanf("%*d"); 49 ans = 0; 50 } 51 52 printf("%d\n", ans); 53 } 54 55 56 int main() { 57 int T; 58 scanf("%d", &T); 59 while (T--) { 60 Do(); 61 } 62 return 0; 63 }
原文:http://www.cnblogs.com/ohyee/p/5399935.html