传送门

这个题题目描述真怪异……就不能说人话吗……

人话:给定长为n的序列A,定义f(s)为集合s内所有元素异或值,求A的所有子集的f值从小到大排列后,q在其中第一次出现的下标对10086取模的值。

首先不难想到构建线性基。线性基有一个良好的性质!假设这n个数的线性基中有k的数,那么显然有\(2^k\)种异或值。之后,因为线性基是可以看作线性基中本来有的数再加上一堆0,所以每一种异或值应该出现过\(2^{n-k}\)次。

那么我们只需要求出来q在这一堆异或值中的排名。这个我们可以仿照求第k大的操作(鬼知道为啥我hdu过不了),看一下代码吧。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#define rep(i,a,n) for(register int i = a;i <= n;i++)
#define per(i,n,a) for(register int i = n;i >= a;i--)
#define enter putchar('\n')
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define sc second
#define I inline
using namespace std;
typedef long long ll;
const int M = 100005;
const int N = 10000005;
const int mod = 10086;
const double eps = 1e-5; int read()
{
int ans = 0,op = 1;char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') op = -1;ch = getchar();}
while(ch >='0' && ch <= '9') ans = ans * 10 + ch - '0',ch = getchar();
return ans * op;
} int n,a[M],p[60],q,b[60],cnt,tot; int inc(int a,int b) {return (a+b) % mod;}
int mul(int a,int b) {return 1ll * (a) * (b) % mod;} int qpow(int a,int b)
{
int c = 1;
while(b)
{
if(b & 1) c = mul(c,a);
a = mul(a,a),b >>= 1;
}
return c;
} void insert(int x)
{
per(i,30,0)
{
if(!((x >> i) & 1)) continue;
if(!p[i]) {p[i] = x;break;}
x ^= p[i];
}
} int main()
{
n = read();
rep(i,1,n) a[i] = read(),insert(a[i]);
rep(i,0,30) if(p[i]) b[cnt++] = i;
q = read();
rep(i,0,cnt-1) if((q >> b[i]) & 1) tot += 1 << i;
printf("%d\n",inc(mul(tot,qpow(2,n-cnt)),1));
return 0;
}

最新文章

  1. MSSQLServer 纵向表转横向表 横向表转纵向表 行转列 列转行
  2. PostgreSQL ROW_NUMBER() OVER()
  3. Bootstrap:表格和栅格分页
  4. uva 122 trees on the level——yhx
  5. ftp的20 21端口和主动被动模式
  6. C# 数据回滚
  7. UIView的frame的扩展分类,轻松取出x、y、height、width等值
  8. 这篇blog只是为了发一张图链到UOJ的博客去..
  9. 【转】Linux系统调用列表
  10. drupal7中CKEditor开启上传图片功能
  11. poj2486 Apple Tree【区间dp】
  12. ORACLE函数之日期时间运算函数
  13. hdu_5775_Bubble Sort(树状数组)
  14. 安装wdcp linux一键安装包云系统客户端教程
  15. inno安装客户端,写注册表url调用客户端
  16. 在vue中scss通过scoped属性设置局部变量如何设置框架样式
  17. python命名空间与作用域
  18. tomcat 的 server.xml配置文件
  19. html form method 属性不支持put,delete请求方式,以及开启spring mvc的rest的方式
  20. android中文api(79)——Gallery

热门文章

  1. Opencv 图片边缘检测和最小外接矩形
  2. myBatis-plus异常提示For input string: &quot;{0=null}&quot;
  3. Office HPDeskjetD2468 打印机电源灯闪烁不停,打印机不工作怎么办
  4. 使用CCriticalSection类的注意事项
  5. 笔记本Charge与Vcore方案
  6. node JS 微信开发
  7. Zabbix 3.0安装
  8. Java中Class.forName()的作用(转载)
  9. 有趣的Ruby-学习笔记3
  10. 使用UIWebView载入本地或远程server上的网页