BZOJ 3687 简单题
bitset维护某个和是否存在。
bit<<x:所有子集的和+x。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#define maxn 2000050
using namespace std;
bitset <maxn> bit;
int n,x,ans=,sum=;
int main()
{
scanf("%d",&n);bit[]=;
for (int i=;i<=n;i++)
{
scanf("%d",&x);
sum+=x;bit^=(bit<<x);
}
for (int i=;i<=sum;i++)
if (bit[i]) ans^=i;
printf("%d\n",ans);
return ;
}
BZOJ 3687 简单题的更多相关文章
- BZOJ 3687: 简单题 bitset
3687: 简单题 Time Limit: 10 Sec Memory Limit: 512 MB[Submit][Status][Discuss] Description 小呆开始研究集合论了,他 ...
- bzoj 3687 简单题——bitset
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3687 关于 bitset :https://blog.csdn.net/snowy_smil ...
- [bzoj 3687]简单题 bitset的运用
题意 给定一个正整数集,求所有子集算术和的异或和 题解 每次加入一个元素x,用原集合a xor (a<< x) 然后每一个值统计一下 bitset看起来很优越,是一个能位运算的布尔数组 ...
- BZOJ 3687: 简单题(dp+bitset)
传送门 解题思路 设\(f(i)\)表示和为\(i\)时的方案数,那么转移方程为\(f(i)+=f(i-x)\),\(x\)为当前枚举到的数字,这样做是\(O(n\sum a_i)\)的,考虑优化.发 ...
- 3687: 简单题(bitset)
3687: 简单题 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 700 Solved: 319[Submit][Status][Discuss] ...
- BZOJ 2683: 简单题
2683: 简单题 Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 913 Solved: 379[Submit][Status][Discuss] ...
- bzoj 4066: 简单题 kd-tree
4066: 简单题 Time Limit: 50 Sec Memory Limit: 20 MBSubmit: 234 Solved: 82[Submit][Status][Discuss] De ...
- BZOJ 2683: 简单题(CDQ分治 + 树状数组)
BZOJ2683: 简单题(CDQ分治 + 树状数组) 题意: 你有一个\(N*N\)的棋盘,每个格子内有一个整数,初始时的时候全部为\(0\),现在需要维护两种操作: 命令 参数限制 内容 \(1\ ...
- BZOJ 2683: 简单题 [CDQ分治]
同上题 那你为什么又发一个? 因为我用另一种写法又写了一遍... 不用排序,$CDQ$分治的时候归并排序 快了1000ms... #include <iostream> #include ...
随机推荐
- Uva---10881 Piotr's Ants(蚂蚁)
Problem DPiotr's AntsTime Limit: 2 seconds "One thing is for certain: there is no stopping them ...
- js 时间处理
1.格式化时间 function GetDateTimeFormatter(value) { if (value == undefined) { return &q ...
- springMvc配置编码过滤器
在web.xml中配置 <!-- 编码过滤器 --> <filter> <filter-name>characterEncodingFilter</filte ...
- Zookeeper注册节点的掉线自动重新注册及测试方法
转载:http://www.codelast.com/ 在一套分布式的online services系统中,各service通常不会放在一台服务器上,而是通过Zookeeper这样的东西,将自己的se ...
- placeholder在ie789下无效
<input type="text" class="input" placeholder="用户名/手机号码/邮箱" value=&q ...
- sqlserver获取表名,字段名
一.获取表的基本信息 SELECT [TableName] = [Tables].name , [TableOwner] = [Schemas].name , [TableCreateDate] = ...
- centos 5.8 64位系统安装 mysql5.6
mysql5.5以上的版本编译需要 cmake 1 .安装cmake wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.g ...
- JavaScript中字符串转Json方法小记
例如: JSON字符串:var str1 = '{ "name": "cxh", "sex": "man" }'; JS ...
- ng-repeat的group
http://blog.csdn.net/violet_day/article/details/17023219 一.obj包含 <!doctype html> <html ng- ...
- [转载]Android 异步加载解决方案
2013-12-25 11:15:47 Android 异步加载解决方案,转载自: http://www.open-open.com/lib/view/open1345017746897.html 请 ...