1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| #include <bits/stdc++.h> #define FOR(i, x, y) for (__typeof(y) i = (x), _##i = (y); i < _##i; ++i) #define FORD(i, x, y) for (__typeof(x) i = (x), _##i = (y); i > _##i; --i) using namespace std; typedef long long LL; const int MOD = 1E9 + 7; const int maxn = 8192 + 10; bool p[maxn]; int t, a[5000], T, n, u; LL dp[2][maxn];
int main() { for (int i = 2; i < maxn; ++i) if (!p[i]) for (int j = i + i; j < maxn; j += i) p[j] = 1; scanf("%d", &T); while (T--) { memset(dp, 0, sizeof dp); u = 0; dp[0][0] = 1; memset(a, 0, sizeof a); scanf("%d", &n); FOR(i, 0, n) { scanf("%d", &t); ++a[t]; } FOR(i, 3500, 4501) if (a[i]) { u ^= 1; FOR(j, 0, 8192) dp[u][j] = ((1 + a[i] / 2) * dp[u ^ 1][j] + (a[i] + 1) / 2 * dp[u ^ 1][j ^ i]) % MOD; } LL ans = 0; FOR(i, 2, 8192) if (!p[i]) ans += dp[u][i]; printf("%lld\n", ans % MOD); } }
|