Time Limit: 6 Sec  Memory Limit: 128 MB
Submit: 2054  Solved: 850
[Submit][Status][Discuss]

Description

已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2^S定义为S 所有子
集构成的集合。定义映射 f : 2^S -> Zf(空集) = 0f(T) = XOR A[t] , 对于一切t属于T现在albus把2^S中每个集
合的f值计算出来, 从小到大排成一行, 记为序列B(下标从1开始)。 给定一个数, 那么这个数在序列B中第1
次出现时的下标是多少呢?

Input

第一行一个数n, 为序列A的长度。接下来一行n个数, 为序列A, 用空格隔开。最后一个数Q, 为给定的数.

Output

共一行, 一个整数, 为Q在序列B中第一次出现时的下标模10086的值.
 

Sample Input

3
1 2 3
1

Sample Output

3
样例解释:
N = 3, A = [1 2 3]
S = {1, 2, 3}
2^S = {空, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
f(空) = 0
f({1}) = 1
f({2}) = 2
f({3}) = 3
f({1, 2}) = 1 xor 2 = 3
f({1, 3}) = 1 xor 3 = 2
f({2, 3}) = 2 xor 3 = 1
f({1, 2, 3}) = 0
所以
B = [0, 0, 1, 1, 2, 2, 3, 3]

HINT

数据范围:

1 <= N <= 10,0000

其他所有输入均不超过10^9

Source

 
这种题自己根本想不出来啊qwq。。。

 
  1. // luogu-judger-enable-o2
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<algorithm>
  5. #include<queue>
  6. #define int long long
  7. using namespace std;
  8. const int MAXN = 1e5 + , B = , mod = ;
  9. inline int read() {
  10. char c = getchar(); int x = , f = ;
  11. while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
  12. while(c >= '' && c <= '') x = x * + c - '', c = getchar();
  13. return x * f;
  14. }
  15. int N, a[MAXN], P[MAXN];
  16. void Insert(int x) {
  17. for(int i = B; i >= ; i--) {
  18. if((x >> i) & ) {
  19. if(!P[i]) {P[i] = x; return ;}
  20. x = x ^ P[i];
  21. }
  22. }
  23. }
  24. void Gauss() {
  25. for(int i = B; i >= ; i--)
  26. if(P[i])
  27. for(int j = i + ; j <= B; j++)
  28. if((P[j] >> i) & )
  29. P[j] ^= P[i];
  30. }
  31. int num = , pos[MAXN];
  32. void ReMove() {
  33. for(int i = ; i <= B; i++)
  34. if(P[i])
  35. pos[++num] = i;
  36. }
  37. int fastpow(int a, int p) {
  38. int base = ;
  39. while(p) {
  40. if(p & ) base = (base * a) % mod;
  41. a = (a * a) % mod; p >>= ;
  42. }
  43. return base;
  44. }
  45. main() {
  46. #ifdef WIN32
  47. freopen("a.in", "r", stdin);
  48. #endif
  49. N = read();
  50. for(int i = ; i <= N; i++) a[i] = read(), Insert(a[i]);
  51. Gauss();
  52. ReMove();
  53. int Q = read(), ans = ;
  54. for(int i = ; i <= num; i++)
  55. if((Q & (1ll << pos[i])))
  56. ans = ans ^ ( << i - );
  57. printf("%lld\n", (ans * fastpow(, N - num) + ) % mod);
  58. }

BZOJ2844: albus就是要第一个出场(线性基)的更多相关文章

  1. bzoj 2844 albus就是要第一个出场 - 线性基

    题目传送门 这是个通往vjudge的虫洞 这是个通往bzoj的虫洞 题目大意 给定集合$S$,现在将任意$A\subseteq S$中的元素求异或和,然后存入一个数组中(下标从1开始),然后从小到大排 ...

  2. albus就是要第一个出场(线性基)

    传送门 这个题题目描述真怪异--就不能说人话吗-- 人话:给定长为n的序列A,定义f(s)为集合s内所有元素异或值,求A的所有子集的f值从小到大排列后,q在其中第一次出现的下标对10086取模的值. ...

  3. 【贪心】【线性基】bzoj2844 albus就是要第一个出场

    引用题解:http://blog.csdn.net/PoPoQQQ/article/details/39829237 注意评论区. #include<cstdio> using names ...

  4. 【线性基】bzoj2844: albus就是要第一个出场

    线性基求可重rank 题目描述 给定 n 个数 $\{ a_i \}$ ,以及数 $x$. 将 $\{ a_i \}$​ 的所有子集(包括空集)的异或值从小到大排序,得到 $\{ b_i \} $. ...

  5. BZOJ2844: albus就是要第一个出场

    Description 已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2^S定义为S 所有子集构成的集合. 定义映射 f ...

  6. bzoj千题计划195:bzoj2844: albus就是要第一个出场

    http://www.lydsy.com/JudgeOnline/problem.php?id=2844 题意:给定 n个数,把它的所有子集(可以为空)的异或值从小到大排序得到序列 B,请问 Q 在  ...

  7. 【BZOJ2844】albus就是要第一个出场 高斯消元求线性基

    [BZOJ2844]albus就是要第一个出场 Description 已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2 ...

  8. CF895C: Square Subsets && 【BZOJ2844】albus就是要第一个出场

    CF895C: Square Subsets && [BZOJ2844]albus就是要第一个出场 这两道题很类似,都是线性基的计数问题,解题的核心思想也一样. CF895C Squa ...

  9. BZOJ 2844: albus就是要第一个出场 [高斯消元XOR 线性基]

    2844: albus就是要第一个出场 题意:给定一个n个数的集合S和一个数x,求x在S的$2^n$个子集从小到大的异或和序列中最早出现的位置 一开始看错题了...人家要求的是x第一次出现位置不是第x ...

随机推荐

  1. centos-7.2 node.js免编译安装

    cd /usr/local/ wget https://npm.taobao.org/mirrors/node/v8.9.3/node-v8.9.3-linux-x64.tar.gz tar -zxv ...

  2. Elipse plugin or Bundle & OSGI

    Develop and register service, lookup and use service! Android Design on service's publish-find-bind ...

  3. Sde各类命令详解(sdemon 、sdelayer、sdeservice、sdetable、sdeconfig、SdeExport_SdeImport)

      Sdemon命令详解: http://wenku.baidu.com/view/3b53e8ec0975f46527d3e1c2.html 1.重建空间索引       D:\Program Fi ...

  4. htmlunit模拟登录

    htmlunit jar项目路径http://sourceforge.net/projects/htmlunit/files/htmlunit/ demo代码如下 public class AutoL ...

  5. 【Leetcode】【Easy】Minimum Depth of Binary Tree

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  6. 通过vue-cli3构建一个SSR应用程序

    1.前沿 1.1.什么是SSR SSR(服务端渲染)顾名思义就是将页面在服务端渲染完成后在客户端直接展示. 1.2.客户端渲染与服务端渲染的区别 传统的SPA模式 即客户端渲染的模式 Vue.js构建 ...

  7. Quartus II管脚批量分配文件(.tcl)格式

    package require ::quartus::project set_location_assignment PIN_E1 -to clk set_location_assignment PI ...

  8. 关于simotion建立同步/解除同步的问题

    关于simotion建立同步/解除同步的问题. 问题: [enable gearing][disable gearing][enable camming][disable camming]都是一个过程 ...

  9. NO.002-2018.02.07《越人歌》先秦:佚名

    参考之后略有修改,疑问点“不訾诟耻”释义 越人歌原文.翻译及赏析_古诗文网 蒙羞被好兮不訾诟耻_释义_吴江诗词网   越人歌 先秦:佚名 今夕何夕兮,搴舟中流.今晚是怎样的晚上啊河中漫游.搴(qiān ...

  10. selenium+python自动化登录脚本

    利用selenium+python写的一个关于登录的自动化脚本