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
 
 
  1. #include<iostream>
  2. #include<cstring>
  3. #include<cstdio>
  4. #define ll __int64
  5. using namespace std;
  6. int t;
  7. int n;
  8. ll exm;
  9. int main()
  10. {
  11. int t;
  12. scanf("%d",&t);
  13. for(int i=;i<=t;i++)
  14. {
  15. scanf("%d",&n);
  16. for(int j=;j<=n;j++)
  17. scanf("%I64d",&exm);
  18. if(n==)
  19. printf("%I64d\n",exm);
  20. else
  21. cout<<""<<endl;
  22. }
  23. return ;
  24. }

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. leetcode-二叉树的层次遍历(Java)

    给定一个二叉树,返回其按层次遍历的节点值. (即逐层地,从左到右访问所有节点). 例如:给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层 ...

  2. github项目切换远程https到ssh通道

    github 切换远程https到ssh通道 github 每个仓库有两类地址:https和ssh通道. https通道获取代码方便,提交过程中每次都需要输入用户名和密码. ssh通道需要提前配置号s ...

  3. 使用Zabbix监控rabbitmq服务

    添加rabbitmq脚本 [root@controller rabbitmq]# cd /etc/zabbix/script/rabbitmq [root@controller rabbitmq]# ...

  4. 基于Kubernetes(k8s)的RabbitMQ 集群

    目前,有很多种基于Kubernetes搭建RabbitMQ集群的解决方案.今天笔者今天将要讨论我们在Fuel CCP项目当中所采用的方式.这种方式加以转变也适用于搭建RabbitMQ集群的一般方法.所 ...

  5. JS判断是IOS还是Android以及如何解决h5打包后在ios下内容与状态栏重叠问题

    h5打包后在ios下内容与状态栏重叠问题: 1:知道设备的类型: var u = navigator.userAgent, app = navigator.appVersion; var isAndr ...

  6. Thunder团队第六周 - Scrum会议3

    Scrum会议3 小组名称:Thunder 项目名称:i阅app Scrum Master:李传康 工作照片: 参会成员: 王航:http://www.cnblogs.com/wangh013/ 李传 ...

  7. thrift多平台安装

    thrift支持多语言的RPC,一直都想深入学习了解thrift,最近有空,就上网查了些资料,学习了一下,对它的使用有了一些了解.本篇是写thrift的安装,使用方法会另起一篇来写. 本文使用thri ...

  8. BER-TLV数据结构

    本文是自身在研究学习过程中碰到的问题,整理而成. 为了便于后文的引用说明,先列出一段TLV结构的数据: [6F] 4D │ ├─[] A0000003330101 │ ├─[A5] │ │ ├─[] ...

  9. Redis Cluster实现原理

    一.Redis Cluster主要特性和设计     集群目标 1)高性能和线性扩展,最大可以支撑到1000个节点:Cluster架构中无Proxy层,Master与slave之间使用异步replic ...

  10. WPF DataGrid的使用

    构造数据: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sy ...