BZOJ3687:bitset STL
题意:集合的子集的算术和的异或和
题解:bitset
二进制倒数第i位为1代表集合的和i出现过奇数次
例:1 2 3
初始: 000000001
<<1:000000010
异或: 000000011
<<2:000001100
异或: 000001111
<<3:001111000
异或: 001110111
#include<stdio.h>
#include<bitset>
using namespace std;
int n,x,sum,ans;
bitset<> a;
int main()
{
scanf("%d",&n);
a[]=;
while(n--)
{
scanf("%d",&x);
sum+=x;
a^=(a<<x);
}
for(int i=;i<=sum;i++)
if(a[i])ans^=i;
printf("%d",ans);
return ;
}
BZOJ3687:bitset STL的更多相关文章
- 转:详细解说 STL 排序(Sort)
详细解说 STL 排序(Sort) 详细解说 STL 排序(Sort) 作者Winter 详细解说 STL 排序(Sort) 0 前言: STL,为什么你必须掌握 1 STL提供的Sort 算法 1. ...
- C++:bitset用法
std::bitset是STL的一部分,准确地说,std::bitset是一个模板类,它的模板参数不是类型,而整形的数值(这一特性是ISO C++2003的新特性),有了它我们可以像使用数组一样使用位 ...
- C++标准库:bitset 用法整理&&zoj 3812
转载: http://happyboy200032.blog.163.com/blog/static/46903113201291252033712/ 头文件:#include <bits/st ...
- 转载:C++ STL set学习
声明:本文转载自Penguin的博客 http://blog.sina.com.cn/s/blog_779cf3410101389s.html 1,set的含义是集合,它是一个有序的容器,里面的元素都 ...
- 转:用STL中的vector动态开辟二维数组
用STL中的vector动态开辟二维数组 源代码:#include <iostream>#include <vector>using namespace std;int mai ...
- 数据结构:Bitset
这个东西看起来很棒棒的样子呀 bitset存储二进制数位 bitset就像一个bool类型的数组一样 bitset中的每个元素都能单独被访问 整数类型和布尔数组都能转化成bitset 有关Bitset ...
- Three.js基础:导入STL模型文件
stlloadertest.html: <!DOCTYPE html> <html lang="en"> <head> <title> ...
- 吴裕雄--天生自然C++语言学习笔记:C++ STL 教程
C++ STL(标准模板库)是一套功能强大的 C++ 模板类,提供了通用的模板类和函数,这些模板类和函数可以实现多种流行和常用的算法和数据结构,如向量.链表.队列.栈. C++ 标准模板库的核心包括以 ...
- 查漏补缺:C++STL简述(容器部分)
STL:是Standard Template Library的简称,中文译为标准模板库,是由惠普实验室开发的一系列软件的统称,现为C++的一部分,可分为容器(containers).迭代器(itera ...
随机推荐
- logstash5.x改变
5.x版本 logstash中 elasticsearch插件的workers,无法配置大于1,会提示 This plugin uses the shared and doesn't need thi ...
- struts2中的addActionError 、addFieldError、addActionMessage的方法
一 addActionError ①概念addActionError是Action级别的错误消息 ②添加this.addActionError("错误信息"); ③显示<s: ...
- 响应式框架pure--来自雅虎
梦想还是要有 http://www.purecss.org/
- 夺命雷公狗—angularjs—20—$watch监听的用法
- css3颜色渐变
从上到下的线性渐变: #grad { background: -webkit-linear-gradient(red, blue); /* Safari 5.1 - 6.0 */ backgrou ...
- 字符串核对之Boyer-Moore算法
算法说明: 在计算机科学里,Boyer-Moore字符串搜索算法是一种非常高效的字符串搜索算法.它由Bob Boyer和J Strother Moore设计于1977年.此算法仅对搜索目标字符串(关键 ...
- Length of Last Word
class Solution { public: int lengthOfLastWord(string s) { ; ; while(s[i]&&s[i]==' ') i++; // ...
- [转]centos中wget的使用方法
本文转自 http://www.cnblogs.com/chusiping/archive/2011/11/10/2243805.html 和 http://www.jb51.net/os/RedHa ...
- Recovery with Incremental Backups
During media recovery, RMAN examines the restored files to determine whether it can recover them wit ...
- PHP数组的一些常用函数
[数组排序]sort()低到高,rsort()高到低.保持键值对应关系使用 asort()和arsort().对键排序ksort()和krsort().随机排序 shuffle(). [数组key相关 ...