题意:https://ac.nowcoder.com/acm/contest/1109/C

问你有几个x满足A,B集合都能XOR出x。

思路:

就是线性基求交后,有几个基就是2^几次方。

 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
//******************
int abss(int a);
int lowbit(int n);
int Del_bit_1(int n);
int maxx(int a,int b);
int minn(int a,int b);
double fabss(double a);
void swapp(int &a,int &b);
clock_t __STRAT,__END;
double __TOTALTIME;
void _MS(){__STRAT=clock();}
void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
//***********************
#define rint register int
#define fo(a,b,c) for(rint a=b;a<=c;++a)
#define fr(a,b,c) for(rint a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
const double E=2.718281828;
const double PI=acos(-1.0);
//const ll INF=(1LL<<60);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; struct node
{
long long base[]; void Init()
{
for(int i=;i<;++i)
base[i]=;
} bool check(long long x)
{
for(int i=;i>=;--i)
{
if(x&(1LL<<i))
{
if(!base[i])return ;
else x^=base[i];
}
}
return ;
} void Insert(long long x)
{
for(int i=;i>=;--i)
{
if(x>>i&)
{
if(base[i])
x^=base[i];
else
{
base[i]=x;
break;
}
}
}
}
}BASE[],temp,v,ans; ll a[N],b[N];
void merge(const node &a,node &b,node &ans)
{// https://blog.csdn.net/qcwlmqy/article/details/97584411
temp=v=a;
fo(i,,)
{
if(b.base[i])
{
long long x=b.base[i],now=;
int g=;
for(int j=;j>=;j--)
{
if(x>>j&)
{
if(!temp.base[j])
{
g=;
temp.base[j]=x;
v.base[j]=now;
break;
}
x^=temp.base[j];now^=v.base[j];
}
}
if(!g)
ans.Insert(now);
}
}
}
int main()
{
int n;
while(~sc("%d",&n))
{
BASE[].Init();
BASE[].Init();
ans.Init();
for(int i=;i<=n;++i)
sc("%lld",&a[i]),BASE[].Insert(a[i]);
for(int i=;i<=n;++i)
sc("%lld",&b[i]),BASE[].Insert(b[i]);
merge(BASE[],BASE[],ans);
int cnt=;
for(int i=;i<;++i)
if(ans.base[i])
cnt++;
ll ANS=;
for(int i=;i<=cnt;++i)
ANS*=;
pr("%lld\n",ANS);
}
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}

线性基求交(2019牛客国庆集训派对day4)的更多相关文章

  1. 2019牛客国庆集训派对day5

    2019牛客国庆集训派对day5 I.Strange Prime 题意 \(P=1e10+19\),求\(\sum x[i] mod P = 0\)的方案数,其中\(0 \leq x[i] < ...

  2. 计算几何板子题【2019牛客国庆集训派对day7——三角形和矩形】【多边形相交的面积】

    链接:https://ac.nowcoder.com/acm/contest/1112/J来源:牛客网 题目描述 Bobo 有一个三角形和一个矩形,他想求他们交的面积. 具体地,三角形和矩形由 8 个 ...

  3. 2019 牛客国庆集训派对day1-C Distinct Substrings(exkmp+概率)

    链接:https://ac.nowcoder.com/acm/contest/1099/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...

  4. 2019牛客国庆集训派对day7 A 2016

    链接:https://ac.nowcoder.com/acm/problem/52800来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K ...

  5. 牛客国庆集训派对Day4 J-寻找复读机

    链接:https://www.nowcoder.com/acm/contest/204/J 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...

  6. 牛客国庆集训派对Day4 I-连通块计数(思维,组合数学)

    链接:https://www.nowcoder.com/acm/contest/204/I 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...

  7. 2018 牛客国庆集训派对Day4 - H 树链博弈

    链接:https://ac.nowcoder.com/acm/contest/204/H来源:牛客网 题目描述 给定一棵 n 个点的树,其中 1 号结点是根,每个结点要么是黑色要么是白色 现在小 Bo ...

  8. 2019牛客国庆集训派对day3

    E. Grid 大意: 给定$n\cdot m$个点的图, 初始无边, $q$个操作, $(1,a,b)$表示第$a$列到第$b$列全连起来, $(2,a,b)$表示把第$a$行到第$b$行全连起来, ...

  9. 图论+思维(2019牛客国庆集训派对day2)

    题意:https://ac.nowcoder.com/acm/contest/1107/J n个点的完全图编号0-n-1,第i个点的权值为2^i,原先是先手选取一些边,然后后手选取一些点,满足先手选取 ...

随机推荐

  1. Postman集合/文件夹/请求中脚本的执行顺序

    Postman的Collection(集合)/Folder(集合的子文件夹)/Request(请求)中都有Pre-request Script(请求前脚本)和Tests(请求后脚本) 这个功能类似于不 ...

  2. load加载层

    //eg1 var index = layer.load(); //eg2 var index = layer.load(1); //换了种风格 //eg3 var index = layer.loa ...

  3. ARP输入 之 arp_rcv

    概述 arp_rcv是ARP包的入口函数,ARP模块在二层注册了类型为ETH_P_ARP的数据包回调函数arp_rcv,当收到ARP包时,二层进行分发,调用arp_rcv: arp_rcv对ARP输入 ...

  4. 第11组 Alpha冲刺(3/6)

    第11组 Alpha冲刺(3/6)   队名 不知道叫什么团队 组长博客 https://www.cnblogs.com/xxylac/p/11872098.html 作业博客 https://edu ...

  5. LC 718. Maximum Length of Repeated Subarray

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arra ...

  6. Django运行项目时候出现DisallowedHost at / Invalid HTTP_HOST header:

    web端错误现象: DisallowedHost at / Invalid HTTP_HOST header: 'ip:8000'. You may need to add u'ip' to ALLO ...

  7. rally task配置文件

    rally task配置文件 Rally本身提供了一些task配置文件,用于提供测试用例中所需的信息包括场景测试中所传入的参数.运行方式是并行还是串行,context等信息.Rally本身提供的tas ...

  8. Java之分布式事务TCC

    看这个博客吧! 挺好的. 理论:https://www.cnblogs.com/jajian/p/10014145.html 实践:https://www.cnblogs.com/sessionbes ...

  9. 九十:CMS系统之项目结构

    目录结构 cms模块 from flask import Blueprint bp = Blueprint('cms', __name__, url_prefix='/cms') @bp.route( ...

  10. Python中webbrowser的用法

    #coding:utf-8 import time import webbrowser as web import os import random #随机选择一个浏览器打开网页 def open_u ...