状压DP
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[1<<17][180];
int b[1<<17];
int s[1<<17];
int main() {
int N, a[20];
while (~scanf("%d", &N)) {
for (int i = 0; i < N; ++i) scanf("%d", a+i);
for (int i = 0; i < N; ++i) b[1<<i] = i;
int up = 1<<N;
for (int i = 0; i < up; ++i) memset(dp[i], 0x00, sizeof(dp[0]));
dp[0][0] = 1;
for (int i = 1; i < up; ++i) {
int j = i - (i&(i-1)); j = b[j];
int k = i - (1<<j);
s[i] = s[k] ^ a[j];
for (int m = 0; m < 128; ++m) {
if ((m ^ a[j]) >= 128) continue;
dp[i][m^a[j]] += dp[k][m];
dp[i][m] += dp[k][m];
}
}
ll ans = 0;
for (int i = 0; i < up; ++i) {
int j = (~i) & (up-1);
for (int k = 0; k <= s[i]; ++k) ans += dp[j][k];
}
cout << ans << endl;
}
return 0;
}