so easy

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5650

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}

Hint

题意

给你一个集合S,然后定义F(s)表示这个集合所有元素的异或和。

然后求所有S的子集的F(s)的异或和

题解:

考虑每个数的贡献,显然当n>1的时候,每个数在2^(n-1)个集合里面,所以贡献为0

当n=1的时候,答案就是x啦

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1050;
int a[maxn];
void solve()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
if(n==1)printf("%d\n",a[1]);
else printf("0\n");
}
int main()
{
int t;scanf("%d",&t);
while(t--)solve();
return 0;
}

HDU 5650 so easy 数学的更多相关文章

  1. HDU 4565 So Easy! 数学 + 矩阵 + 整体思路化简

    http://acm.hdu.edu.cn/showproblem.php?pid=4565 首先知道里面那个东西,是肯定有小数的,就是说小数部分是约不走的,(因为b限定了不是一个完全平方数). 因为 ...

  2. hdu 5650 so easy (异或)

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

  3. HDU 5650 so easy

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

  4. HDU 5572 An Easy Physics Problem (计算几何+对称点模板)

    HDU 5572 An Easy Physics Problem (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5572 Descripti ...

  5. 5650 so easy

    so easy  Accepts: 512  Submissions: 1601  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 6553 ...

  6. 数学(矩阵乘法):HDU 4565 So Easy!

    So Easy! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  7. HDU 4565 So Easy!(数学+矩阵快速幂)(2013 ACM-ICPC长沙赛区全国邀请赛)

    Problem Description A sequence Sn is defined as:Where a, b, n, m are positive integers.┌x┐is the cei ...

  8. 数学--数论-- HDU 2601 An easy problem(约束和)

    Problem Description When Teddy was a child , he was always thinking about some simple math problems ...

  9. hdu 5058 So easy

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5058 So easy Description Small W gets two files. Ther ...

随机推荐

  1. ckeditor+ckfinder+java

    (java)Ckdeitor+ckfinder整合 第一步:工具下载 首先下载:CKEditor 地址:http://cdeditor.com/dowmload 接着下载CKFinder 地址:htt ...

  2. [002] delete_duplication_of_linked_list

    [Description] Given a unsort linked list, delete all the duplication from them, no temporary space p ...

  3. BZOJ 2049: [Sdoi2008]Cave 洞穴勘测——LCT

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2049 省选之前来切一道数据结构模板题. 题意 这是一道模板题. N个点,M次操作,每次加边/ ...

  4. caffe Python API 之BatchNormal

    net.bn = caffe.layers.BatchNorm( net.conv1, batch_norm_param=dict( moving_average_fraction=0.90, #滑动 ...

  5. C/C++——C语言常用库函数

    本文转载自:https://blog.csdn.net/qq_36955347/article/details/71511900 一.数学函数 调用数学函数时,要求在源文件中包下以下命令行: #inc ...

  6. 浅谈Java中的hashcode方法(转)

    原文链接:http://www.cnblogs.com/dolphin0520/p/3681042.html 浅谈Java中的hashcode方法 哈希表这个数据结构想必大多数人都不陌生,而且在很多地 ...

  7. 构建基于TCP的应用层通信模型

    各层的关系如下图,表述的是两个应用或CS间通信的过程:   通常使用TCP构建应用时,需要考虑传输层的通信协议,以便应用层能够正确识别消息请求.比如,一个请求的内容很长(如传文件),那肯定要分多次发送 ...

  8. Linux命令参数处理 shell脚本函数getopts

    getopts 命令 用途 处理命令行参数,并校验有效选项. 语法 getopts 选项字符串 名称 [ 参数 ...] 描述 getopts 的设计目标是在循环中运行,每次执行循环,getopts ...

  9. 以太坊go-ethereum客户端JSON-RPC API调用(一)

    前几篇博客主要介绍了go-ethereum客户端不同环境的搭建,今天这篇博客是建立在前几排博客的基础上.当搭建完成之后,我们可以通过各种方式与节点进行交互(JavaScript Console.JSO ...

  10. python selenium自动化测试之路(1)--分层测试概念、selenium工具介绍

    1.分层自动化测试概念 传统的自动化市场更关注产品UI层的自动化测试,而分层的自动化测试倡导产品开发的不同阶段都需要自动化测试 大多公司与研发团队其实是忽略了单元测试与集成测试阶段的自动化测试工作,所 ...