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.

/* ***********************************************
Author :111qqz
Created Time :2016年03月26日 星期六 18时52分14秒
File Name :code/bc/#77/1002.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6const int N=1005;
 7int n;
 8int a[N];
 9int main()
10{
11	#ifndef  ONLINE_JUDGE 
12	freopen("code/in.txt","r",stdin);
13  #endif
1	int T;
2	cin>>T;
3	while (T--)
4	{
5	    scanf("%d",&n);
	    for ( int i = 0 ; i < n ; i++) scanf("%d",&a[i]);
1	    if (n==1)
2	    {
3		printf("%d\n",a[0]);
4	    }
5	    else
6	    printf("0\n");
7	}
1  #ifndef ONLINE_JUDGE  
2  fclose(stdin);
3  #endif
4    return 0;
5}