BestCoder Round #77 (div.2) 1001 so easy

so easy

 

 Accepts: 518

 

 Submissions: 1601

 Time Limit: 2000/1000 MS (Java/Others)
 
 Memory Limit: 65536/65536 K (Java/Others)
Problem Description

Given an array with n integers, assume f(S)f(S) as the result of executing xor operation among all the elements of set SS. e.g. if S = {1,2,3}S={1,2,3} then f(S) = 0f(S)=0.

your task is: calculate xor of all f(s)f(s), here s \subseteq SsS.

Input

This problem has multi test cases. First line contains a single integer T(T\leq 20)T(T20) 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)n(1n1,000) that represents the size of the given set. then the following line consists of nn different integer numbers indicate elements(\leq 10^9109) 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\}S={1,2,3}, subsets of SS are: \varnothing, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}

根据集合子集的规律:所有子集中每个元素出现的总次数为2^(n-1),即此题中当元素个数大于1时相当于每个元素与自身异或2^(n-1)次,结果为0;当元素个数为1 时结果为这个元素本身;

例如:{1,2,3}的结果 =  1^2^3^1^2^1^3^2^3^1^2^3 = 0;一共有四个1,四个2,四个3;



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值