HDU 5650 so easy

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 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

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;
}

时间: 2025-01-21 21:09:07

HDU 5650 so easy的相关文章

hdu 5650 so easy (异或)

我们考虑集合中的每个数x对答案的贡献. 设集合有n个数,则包含x的子集个数有2^(n-1)个. 那么当n > 1时,x出现了偶数次,所以其对答案的贡献就是0:当 n = 1时,其对答案的贡献是 x. AC代码: 1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include<iostream> 3 #include<cstdio> 4 #include<cstring>

杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> /* 题意:找闰年. if((i%4==0 && i%100!=0) || i%400==0)count++; 3 2005 25 1855 12 2004 10000 2108 1904 43236 */ int main() { int t,y,n; int i,count=0; whil

HDU 4565 So Easy!

线性推,矩阵乘法+快速幂求通项. 传送门:点击打开链接 #include <cstdio> #include <cstring> #include <cmath> #include <iostream> using namespace std; #define LL long long struct Mat{ LL f[2][2]; }; LL MOD; Mat mul(Mat a,Mat b) { LL i,j,k; Mat c; memset(c.f,0

HDU 5058 So easy (set容器大法好)

题目链接:HDU 5058 So easy 题意:给出两个序列,问这个两个序列构成的集合是否相同. set大法好! AC代码: #include<stdio.h> #include<set> #include<map> using namespace std; #define ll __int64 set<ll> ss1,ss2; set<ll>::iterator it; int main() { ll n,i; while(scanf(&qu

HDU 4565 So Easy! 矩阵快速幂 + 共轭数

题意:中文题 So Easy 解题思路: 这题应该是 HDU 2256的原题 , 根据类似的结论可以推出 中间矩阵 ta  1 tb ta 原矩阵 1 1 解题代码: 1 // File Name: temp.cpp 2 // Author: darkdream 3 // Created Time: 2014年09月17日 星期三 11时35分45秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #inc

数据结构(主席树):HDU 4729 An Easy Problem for Elfness

An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1148    Accepted Submission(s): 234 Problem Description Pfctgeorge is totally a tall rich and handsome guy. He plans t

HDU 5058 So easy(STL set运用)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5058 Problem Description Small W gets two files. There are n integers in each file. Small W wants to know whether these two files are same. So he invites you to write a program to check whether these two

hdu 1040 As Easy As A+B

As Easy As A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 53368    Accepted Submission(s): 22939 Problem Description These days, I am thinking about a question, how can I get a problem as

HDU 5058 So easy

http://acm.hdu.edu.cn/showproblem.php?pid=5058 题目大意: 给定两个集合,两个集合的元素都为n,求两个集合是否相等. 例如:A集合={5,3,7,7},B集合={7,5,3,3},则A集合等于B集合, 因为他们都有{3,5,7}.C集合={2,5,2,5},D集合={2,5,2,3},C集合和B集合是不等的. 因为C={2,5},D={2,3,5} 解题思路: 对A集合和B集合排序,然后去掉重复的元素,再比较. AC代码: 1 #include<io