so easy

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

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 s⊆S

.

 
Input
This problem has multi test cases. First line contains a single integer T(T≤20)

which represents the number of test cases.
For each test case, the first line contains a single integer number n(1≤n≤1,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
题意: 给你一个集合S    f(s)代表其子集中的元素的异或值
        输出所有子集的异或值
题解:设集合有n个数,则包含x的子集个数有2^(n-1)个。 那么当n > 1时,x出现了偶数次,所以其对答案的贡献就是0;当 n = 1时,其对答案的贡献是 x。
    (两个相同的数的异或值为0)
5(10)=101(2)
5^5=0
  101
  101
=000
 
 
 #include<iostream>
#include<cstring>
#include<cstdio>
#define ll __int64
using namespace std;
int t;
int n;
ll exm;
int main()
{
int t;
scanf("%d",&t);
for(int i=;i<=t;i++)
{
scanf("%d",&n);
for(int j=;j<=n;j++)
scanf("%I64d",&exm);
if(n==)
printf("%I64d\n",exm);
else
cout<<""<<endl;
}
return ;
}

HDU 5650 异或的更多相关文章

  1. HDU 5968 异或密码

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. hdu 5650 so easy (异或)

    我们考虑集合中的每个数x对答案的贡献. 设集合有n个数,则包含x的子集个数有2^(n-1)个. 那么当n > 1时,x出现了偶数次,所以其对答案的贡献就是0:当 n = 1时,其对答案的贡献是 ...

  3. HDU 5650 so easy 数学

    so easy 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5650 Description Given an array with n integ ...

  4. HDU 5968 异或密码 【模拟】 2016年中国大学生程序设计竞赛(合肥)

    异或密码 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Des ...

  5. hdu 5014 异或序列

    http://acm.hdu.edu.cn/showproblem.php?pid=5014 从最大的一个数开始找能配对使他们的异或值最大的一个数 最后输出 #include <cstdio&g ...

  6. hdu 4768 异或运算

    http://acm.hdu.edu.cn/showproblem.php?pid=4768 貌似非常多人是用的二分 可是更好的做法貌似还是异或 对于第k个人.假设他接到偶数个传单.那么异或的结果还是 ...

  7. HDU 5968(异或计算 暴力)

    题意是在一个数列中找到一段连续的子串使其异或值与所给值最接近,求出子串长度,若有多组结果,输出最大长度. 做题之前一定多注意数据范围,这道题就可以直接暴力,用数组 p[ i ][ j ] 表示长度为 ...

  8. HDU 5650 so easy

    n不为1的时候输出a[1],否则输出0 #include<cstdio> #include<cstring> #include<cmath> #include< ...

  9. HDU 5014 异或之和

    http://acm.hust.edu.cn/vjudge/contest/122814#problem/H 这道题就是求异或之和 知识点: a^b = c 等价于 b^c =a 和 a^c = b ...

随机推荐

  1. 【token接口】-jmeter

    token 接口 3步骤 1.登录接口 2.提取登录接口的token 3.http 信息管理头   把提取的cookie传入  就可以了

  2. CDH问题集

    1.在CM中添加主机报JDK错误 手动在机器上安装oracle-jdk1.7+update64.然后在CM中选择不安装oracle-jdk即可. 2.HostMoinitor无法与server联系 查 ...

  3. [leetcode-693-Binary Number with Alternating Bits]

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will a ...

  4. $http.get(...).success is not a function 错误解决

    $http.get(...).success is not a function 错误解决 1.6 新版本的AngularJs中用then和catch 代替了success和error,用PRomis ...

  5. Notes of the scrum meeting before publishing2(12.18)

    meeting time:18:30~20:30p.m.,December 18th,2013 meeting place:3号公寓一层 attendees: 顾育豪                  ...

  6. 软工实践Alpha冲刺(2/10)

    队名:我头发呢队 组长博客 作业博客 杰(组长) 过去两天完成了哪些任务 查看了讯飞开放平台的sdk 查阅了Google Material Design 2的官方文档 接下来的计划 继续打磨UI界面: ...

  7. iOS开发JOSNModel<optional>,<convertondemand>,<index>

    指定定义的key的类型 <optional>表示字段可选,例如 //链接字段是可选的,转换的时候允许link未空 @property (nonatomic,strong) NSString ...

  8. centos设置时间同步

    1.安装ntpdate #yum install ntpdate   2. #cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #ntpdate ...

  9. 不能将多个项传入“Microsoft.Build.Framework.ITaskItem”类型的参数

    项目编译报错: ”对于“GenerateApplicationManifest”任务的“InputManifest”参数是无效值.不能将多个项传入“Microsoft.Build.Framework. ...

  10. How To Disable MacBook ProTrackpad

    How To Disable MacBook Pro Trackpad how to close macbook pro touchpad? https://www.wikihow.com/Chang ...