const int MAXN = 1024; int ipt[MAXN]; LL dp1[MAXN][MAXN], dp2[MAXN][MAXN], sum1[MAXN][MAXN], sum2[MAXN][MAXN]; int main() { int T, n; RI(T); FE(kase, 1, T) { CLR(dp1, 0); CLR(sum1, 0); CLR(dp2, 0); CLR(sum2, 0); RI(n); REP(i, n) RI(ipt[i]); dp1[0][ipt[0]] = sum1[0][ipt[0]] = 1; FF(i, 1, n) { REP(j, MAXN) dp1[i][j ^ ipt[i]] = (sum1[i - 1][j] + dp1[i][j ^ ipt[i]]) % MOD; dp1[i][ipt[i]]++; REP(j, MAXN) sum1[i][j] = (sum1[i - 1][j] + dp1[i][j]) % MOD; } dp2[n - 1][ipt[n - 1]] = sum2[n - 1][ipt[n - 1]] = 1; FED(i, n - 2, 0) { REP(j, MAXN) dp2[i][j & ipt[i]] = (sum2[i + 1][j] + dp2[i][j & ipt[i]]) % MOD; dp2[i][ipt[i]]++; REP(j, MAXN) sum2[i][j] = (sum2[i + 1][j] + dp2[i][j]) % MOD; } LL ans = 0; REP(i, n - 1) REP(j, MAXN) ans = (ans + dp1[i][j] * sum2[i + 1][j]) % MOD; cout << ans << endl; } return 0; }
The Romantic Hero,布布扣,bubuko.com
原文地址:http://blog.csdn.net/wty__/article/details/38322599