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. CodeForces - 1059D(二分+误差)

    链接:CodeForces - 1059D 题意:给出笛卡尔坐标系上 n 个点,求与 x 轴相切且覆盖了所有给出点的圆的最小半径. 题解:二分半径即可.判断:假设当前二分到的半径是 R ,因为要和 x ...

  2. Python3 Tkinter-Menu

    1.创建 from tkinter import * root=Tk() menubar=Menu(root) def hello(): print('Hello Menu!') for item i ...

  3. 十面阿里,七面头条,六个Offer,春招结束

    作者:jkgeekjack链接:https://www.nowcoder.com/discuss/80156?type=0&order=0&pos=13&page=2来源:牛客 ...

  4. 操作系统及Python解释器工作原理讲解

    操作系统介绍 操作系统位于计算机硬件与应用软件之间 是一个协调.管理.控制计算机硬件资源与软件资源的控制程序 操作系统功能: 控制硬件 把对硬件复杂的操作封装成优美简单的接口(文件),给用户或者应用程 ...

  5. Hadoop学习(一):完全分布式集群环境搭建

    1. 设置免密登录 (1) 新建普通用户hadoop:useradd hadoop(2) 在主节点master上生成密钥对,执行命令ssh-keygen -t rsa便会在home文件夹下生成 .ss ...

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

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

  7. HTML5form表单的相关知识总结

    首先在介绍HTML5form表单的新增内容之前,我总结了一下HTML的form表单的内容. <!DOCTYPE html> <html lang="en"> ...

  8. VUE中组件的使用

    关于vue组件引用 使用Nodejs的方法 被引用的组件要暴露 module.exports={}; 引用时 用 var abc= require("组件的路径") 然后 就可以用 ...

  9. AndroidUI设计之 布局管理器 - 详细解析布局实现

    写完博客的总结 : 以前没有弄清楚的概念清晰化 父容器与本容器属性 : android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中, 每个布局管理器 ...

  10. HashMap get()返回值问题

    问题描述:在进行mysql查询必要字段后,需要根据id进行es其它数据字段的查询拼接.使用HashMap以id为key 以查询过来的数据值为value. 代码如下: Map<String,Int ...