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

AC代码:

 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1006
#define inf 1e12
int n;
int a[N];
int main()
{
int t;
scanf("%d",&t);
while(t--){ scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&a[i]);
}
if(n>){
printf("0\n");
continue;
}
if(n==){
int sum = a[];
for(int i=;i<n;i++){
sum=sum^a[i];
}
printf("%d\n",sum);
}
}
return ;
}

hdu 5650 so easy (异或)的更多相关文章

  1. HDU 5650 so easy 数学

    so easy 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5650 Description Given an array with n integ ...

  2. HDU 5650 so easy

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

  3. 5650 so easy

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

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

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

  5. HDU 5650 异或

    so easy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  6. hdu 5058 So easy

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

  7. hdu 5475 An easy problem(暴力 || 线段树区间单点更新)

    http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...

  8. HDU 5475 An easy problem 线段树

    An easy problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...

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

    An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65535/65535 K (J ...

随机推荐

  1. java servlet+jquery+json学习小例子

    引入JSON的jar包: 注意,如果包不全,页面请求servlet时,jquery ajax会返回error:function 弹出error occured!!! HTML Code: <%@ ...

  2. 分享几个社交类网站常用并且也是最好用的jquery类库

    官网都有详细的文档说明,大家自行百度谷歌哈! artZoom:常用于微博,支持图片放大缩小旋转 AutoComplete:自动完成 BackTop:当内容多时出现“返回顶部” CFUpload:批量上 ...

  3. [RxJS] Adding Conditional Logic with Filter

    Often you only want values to proceed through your stream if they meet certain criteria, just as if ...

  4. CC开发问题一

    CC编译成功,启动失败,debug状态下报错如下,未能加载文件或程序集 这个问题查了一些资料,http://blog.csdn.net/shellching/article/details/82947 ...

  5. beini系列_2_beini装入虚拟机

  6. ECshop使用财付通接口支付时出现“[3006]您的请求无效,请重新再试

    ECshop使用财付通接口支付时出现“[3006]您的请求无效,请重新再试.”解决方案\includes\modules\payment\tenpay.php 行 104原来的为 $bill_no = ...

  7. map和reduce

    map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回. map()传入的第一个参数是f,即函数对象本身.由于 ...

  8. php 简单分页

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. django解决跨域请求的问题

    跨域请求可以用jsonp来解决,不过今天我发现一个很好用的包:django-cors-headers 只需要简单地配置一下就可 被请求方的setting.py中的配置如下: INSTALLED_APP ...

  10. Python函数小结(2)-- 装饰器、 lambda

    本篇依然是一篇学习笔记,文章的结构首先讲装饰器,然后讲lambda表达式.装饰器内容较多,先简要介绍了装饰器语法,之后详细介绍理解和使用不带参数装饰器时应当注意到的一些细节,然后实现了一个简单的缓存装 ...