bc #77 div 2 1001 ||hdu 5650 so easy (傻逼题)
题目链接 題意:已知一个包含 nn 个元素的正整数集合 SS,设 f(S)f(S) 为集合 SS 中所有元素的异或(XOR)的结果。 如:S={1,2,3}, 则 f(S) = 0f(S)=0。
给出集合 SS,你需要计算 将所有 f(s)进行异或后的值, s⊆S.
思路:当集合中元素大于1个的时候,每个元素对都会出现偶数次,对答案的贡献为0.
当集合中只有一个元素的时候,设为x,对答案的贡献为x.
1/* ***********************************************
2Author :111qqz
3Created Time :2016年03月26日 星期六 18时52分14秒
4File Name :code/bc/#77/1002.cpp
5************************************************ */
6
7#include <cstdio>
8#include <cstring>
9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33const int N=1005;
34int n;
35int a[N];
36int main()
37{
38 #ifndef ONLINE_JUDGE
39 freopen("code/in.txt","r",stdin);
40 #endif
41
42 int T;
43 cin>>T;
44 while (T--)
45 {
46 scanf("%d",&n);
47
48 for ( int i = 0 ; i < n ; i++) scanf("%d",&a[i]);
49
50 if (n==1)
51 {
52 printf("%d\n",a[0]);
53 }
54 else
55 printf("0\n");
56 }
57
58 #ifndef ONLINE_JUDGE
59 fclose(stdin);
60 #endif
61 return 0;
62}