fwt

#include<bits/stdc++.h>
using namespace std; const int N=1<<19;
const int mod=1000000007;
const int inv2=(mod+1)/2; void fwt(int *a,int n)
{
for(int i=1;i<n;i<<=1)
for(int p=i<<1,j=0;j<n;j+=p)
for(int k=j;k<j+i;k++)
{
int x=a[k],y=a[i+k];
a[k]=(x+y)%mod;
a[i+k]=(x-y+mod)%mod;
}
}
void ifwt(int *a,int n)
{
for(int i=1;i<n;i<<=1)
for(int p=i<<1,j=0;j<n;j+=p)
for(int k=j;k<j+i;k++)
{
int x=a[k],y=a[i+k];
a[k]=1LL*(x+y)*inv2%mod;
a[i+k]=1LL*(x-y+mod)*inv2%mod;
}
}
int a[22][N],n;
int main()
{
scanf("%d",&n);
int s=0;
for(int i=1;i<=n;++i)
{
int x;
scanf("%d",&x);
a[0][x]=1;
s^=x;
}
a[0][0]=1;
fwt(a[0],N);
for(int i=1;i<22;++i)
for(int j=0;j<N;++j)
a[i][j]=1LL*a[i-1][j]*a[0][j]%mod;
if(s==0)printf("%d\n",n);
else
{
for(int i=0;i<22;++i)
{
ifwt(a[i],N);
if(a[i][s])
{
printf("%d\n",n-i-1);
break;
}
}
}
return 0;
}
/******************** ********************/

H.Playing games的更多相关文章

  1. 「NowCoder Contest 295」H. Playing games

    还是见的题太少了 「NowCoder Contest 295」H. Playing games 题意:选出尽量多的数使得异或和为$ 0$ $ Solution:$ 问题等价于选出尽量少的数使得异或和为 ...

  2. 2018牛客网暑假ACM多校训练赛(第八场)H Playing games 博弈 FWT

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round8-H.html 题目传送门 - https://www.no ...

  3. Nowcoder Playing Games ( FWT 优化 DP && 博弈论 && 线性基)

    题目链接 题意 : 给出 N 个数.然后问你最多取出多少石子使得在 NIM 博弈中.后手必胜 分析 :  Nim 博弈模型,后手必胜当且仅当各个堆的石子的数目的异或和为 0 转化一下.变成最少取多少石 ...

  4. POJ 1487:Single-Player Games 浮点数高斯消元

    Single-Player Games Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1287   Accepted: 36 ...

  5. (转) Deep Reinforcement Learning: Playing a Racing Game

    Byte Tank Posts Archive Deep Reinforcement Learning: Playing a Racing Game OCT 6TH, 2016 Agent playi ...

  6. UVA - 11927 Games Are Important (SG)

    Description  Games Are Important  One of the primary hobbies (and research topics!) among Computing ...

  7. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  8. 2012多校3.A(用O(log(n))判断b^k % a == 0)

    Arcane Numbers 1 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  9. PortSentry是入侵检测工具中配置最简单、效果最直接的工具之一

    https://sourceforge.net/projects/sentrytools/ [root@localhost ~]# tar -xzvf portsentry-1.2.tar.gz [r ...

随机推荐

  1. cache与buffer

    Cache 缓存区,是高速缓存,是位于CPU和主内存之间的容量较小但速度很快的存储器,因为CPU的速度远远高于主内存的速度,CPU从内存中读取数据需等待很长的时间,而  Cache保存着CPU刚用过的 ...

  2. 函数指针(pointer to function)——qsort函数应用实例

    一,举例应用 在ACM比赛中常使用 stdlib.h 中自带的 qsort 函数,是教科书式的函数指针应用示范. #include <stdio.h> #include <stdli ...

  3. 20145330 《网络对抗》PC平台逆向破解:注入shellcode 和 Return-to-libc 攻击实验

    20145330 <网络对抗>PC平台逆向破解:注入shellcode 实验步骤 1.用于获取shellcode的C语言代码 2.设置环境 Bof攻击防御技术 需要手动设置环境使注入的sh ...

  4. React 回忆录(三)使用 React 渲染界面

    Hi 各位,欢迎来到 React 回忆录!

  5. 【javascript】数据结构-链表

    // 创建一个链表 function LinkedList(){ // 创建一个Node辅助类,表示需要加入列表的项,它包含一个element属性,即表示需要加入到列表中的值,next属性表示指向下一 ...

  6. Python3基础 list reversed 列表逆转并输出

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  7. 如何创建自己的python包

    写过python的人都知道python最方便也最牛的地方就是它有无数的第三方lib可以直接拿来使用,可以让编写代码变的更容易. 长用的安装第三方lib的方法有easy_install和pip,这两个的 ...

  8. JavaScript 时间格式

    方法1: Date.prototype.Format = function (fmt) { var o = { , //月份 "d+": this.getDate(), //日 = ...

  9. WannaflyCamp 平衡二叉树(DP)题解

    链接:https://www.nowcoder.com/acm/contest/202/F来源:牛客网 题目描述 平衡二叉树,顾名思义就是一棵“平衡”的二叉树.在这道题中,“平衡”的定义为,对于树中任 ...

  10. 1-20 RHEL7的启动原理和服务控制

    大纲: RHEL7启动原理 RHEL7服务启动配置 网络概述 发布内网服务器 ############################################################ ...