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. cnats 使用

    1. 准备 yum install cmakeyum install gcc gcc-c++yum install ncurses ncurses-develyum install openssl o ...

  2. 20145301 赵嘉鑫 《网络对抗》Exp5 MSF基础应用

    20145301 赵嘉鑫 <网络对抗>Exp5 MSF基础应用 一 实验链接 渗透实验一:MS08_067渗透实验 渗透实验二:MS14_064渗透实验  (首用) 渗透实验三:Adobe ...

  3. Python字典猜解

    摘要 目标 使用Python破解WordPress用户密码 使用Python破解zip压缩包密码 思路 通过表单提交项构建数据包,使用字典中的可选字符进行逐一排列组合暴力破解WordPress的用户密 ...

  4. script 加载顺序问题的延展研究

    今天群里有人问为什么会出现脚本的加载顺序与定义脚本顺序不一致的问题,这个问题引起了我的好奇,经过一番调研,有了这篇文章. 这是一个伪命题吗? 首先,W3C 推荐 script 脚本应该被立即加载和执行 ...

  5. HDU1251 统计难题 (字典树模板)题解

    思路:模板题,贴个模板 代码: #include<cstdio> #include<cstring> #include<cstdlib> #include<q ...

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

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

  7. 51NOD 1117 聪明的木匠

    来源:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1117 挑战原题吧  大概 每次挑选最小的两个,合起来 #inclu ...

  8. Codeforces 1091 Good Bye 2018

    占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的rating upt:flag竟然没到,开心. A - New Year and the Christmas Ornament 好像没什么可说的. ...

  9. trigger自动执行事件

    html <button>点击文字变红</button> <p>trigger出发点击事件</p> js $('button').click(funct ...

  10. Spring编译AOP项目报错

    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram ...