题意:
给你b序列和c序列,问你有多少种构造a序列的方法。
思路:
对于某二进制位来说,当其01值确定后,所有序列的该二进制位就确定了,依次来枚举位。
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<map>
#include<queue>
#include<math.h>
using namespace std;
#define ll long long
#define mod 4933ll
ll b[100010],c[100010],ans=1;
int main()
{
int n;
cin>>n;
for(int i = 2; i <= n; i++)
{
cin>>b[i];
}
for(int i = 2; i <= n; i++)cin>>c[i],c[i]=c[i]-b[i];
for(int i = 0; i < 31; i++)
{
int lx = 1,nx = 1;
for(int j = 2; j <= n; j++)
{
ll nowb = (b[j]>>i)&1,nowc = (c[j]>>i)&1;
if(!nowb && nowc)lx=nx=0;
else if(!nowb && !nowc)lx=0;
else if(nowb && nowc)nx=0;
else if(nowb && !nowc)swap(nx,lx);
}
ans*=(lx+nx);
}
cout<<ans<<endl;
}