HDU 5650 so easy
来源:互联网 发布:Python 图形界面编程 编辑:程序博客网 时间:2024/06/05 21:04
so easy
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 617 Accepted Submission(s): 413
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 allf(s) , here s⊆S .
your task is: calculate xor of all
Input
This problem has multi test cases. First line contains a single integerT(T≤20) which represents the number of test cases.
For each test case, the first line contains a single integer numbern(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.
For each test case, the first line contains a single integer number
Output
For each test case, print a single integer as the answer.
Sample Input
131 2 3
Sample Output
0In the sample,$S = \{1, 2, 3\}$, subsets of $S$ are: $\varnothing$, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}
Source
BestCoder Round #77 (div.2)
Recommend
wange2014 | We have carefully selected several similar problems for you: 5674 5673 5672 5671 5670
题意:给出N个数的集合,这个集合的所有子集合的元素异或运算后,再将这些子集合的运算结果进行异或运算,问最后结果。
做这道题需要知道的是异或运算满足交换律(a^b)^(c^d)=a^b^c^d ,并且a^a=0; a^0=a;只有N为1时,集合中的元素只出现奇数次,其他情况集合中的元素都是出现偶数次,所以此时结果都为0;
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){int t,i,j,k,l,m,n; scanf("%d",&t); while(t--) { scanf("%d",&n); scanf("%d",&m); for(i=1;i<n;i++) scanf("%d",&k); if(n==1) printf("%d\n",m); else printf("0\n");}return 0;}
0 0
- HDU 5650 so easy
- HDU 5650 so easy
- HDU 5650:so easy【数学】
- hdu 5650 so easy(水题)
- HDU 5650 so easy 水的666
- HDU 5650 so easy(异或)
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- hdu 4565 So Easy!
- hdu 4565So Easy!
- hdu 4565 So Easy!
- HDU 4565 So Easy!
- HDU 4565 So Easy!
- 浅谈Linux下的LAMP开发环境的搭建及discuz、phpWind、phpBB3、wordpress各种论坛博客的安装
- request.getParameter() 和request.getAttribute() 区别
- 二进制中1的个数
- VS快捷键
- 浅谈dubbo的ExceptionFilter异常处理
- HDU 5650 so easy
- 初识 树链剖分
- leetcode- Number of 1 bits, power of two, power of three
- 一个程序员的产品思维
- Leetcode Reverse Vowels of a String 345
- java --String 常用方法源码整理
- PHP学习02----PHP扩展库
- headfirst in java读书笔记
- HDU 2181哈密顿绕行世界问题(还是DFS)