原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4762
mark一下,有空要好好弄懂
#include<cstdio>
#include<algorithm>
using namespace std;
int read_p,read_ca;
inline int read(){
read_p=;read_ca=getchar();
while(read_ca<''||read_ca>'') read_ca=getchar();
while(read_ca>=''&&read_ca<='') read_p=read_p*+read_ca-,read_ca=getchar();
return read_p;
}
const int MOD=1e9+;
int n,a,mmh[][][];
inline void M(int &x){while(x>=MOD)x-=MOD;while(x<)x+=MOD;}
int main(){
register int i,j,k;
n=read();mmh[][][]=;
for (i=;i<=n;i++){
a=-read();
for (j=;j<;j++)
for (k=j;;k=(k-)&j){
mmh[i&][j][k]=mmh[i&^][j][k];
if (!k) break;
} for (j=;j<;j++)
for (k=j;;k=(k-)&j){
M(mmh[i&][j|a][k^(k&a)]+=mmh[i&^][j][k]);
M(mmh[i&][j|a][(k^(k&a))|(a^(j&a))]-=mmh[i&^][j][k]);
if (!k) break;
}
}
printf("%d\n",mmh[n&][][]);
}