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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#include <cstdio> #include <cctype> #include <cstring> #include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__) #define Debug(s) debug("The message in line %d, Function %s: %s\n", __LINE__, __FUNCTION__, s) #define getchar() (ipos == iend and (iend = (ipos = _ibuf) + fread(_ibuf, 1, __bufsize, stdin), ipos == iend) ? EOF : *ipos++) #define putchar(ch) (opos == oend ? fwrite(_obuf, 1, __bufsize, stdout), opos = _obuf : 0, *opos++ = (ch)) #define __bufsize (1 << 21 | 1)
char _ibuf[__bufsize], _obuf[__bufsize], _stk[50]; char *ipos = _ibuf, *iend = _ibuf, *opos = _obuf, *oend = _obuf + __bufsize, *stkpos = _stk;
struct END { ~END() { fwrite(_obuf, 1, opos - _obuf, stdout); } } __________;
inline int read() { register int x = 0, flag = 1; register char ch; while (!isdigit(ch = getchar())) if (ch == '-') flag = -1; while (x = x * 10 + (ch & 15), isdigit(ch = getchar())); return x * flag; }
template <typename _INT> inline void write(_INT x) { if (x < 0) putchar('-'), x = -x; while (*++stkpos = x % 10 ^ 48, x /= 10, x); while (stkpos != _stk) putchar(*stkpos--); }
template <typename _Tp> inline bool Chkmax(_Tp& x, const _Tp& y) { return x < y ? x = y, true : false; }
template <typename _Tp> inline bool Chkmin(_Tp& x, const _Tp& y) { return x > y ? x = y, true : false; }
const int maxN = 5e5 + 5; const int maxM = 1 << 20; const int mod = 1e9 + 7;
int n, d, sum; int a[maxN]; int f[10][maxM], tmp[maxM];
inline void Mod(int& x) { x >= mod ? x -= mod : 0; }
int main() { #ifndef ONLINE_JUDGE freopen("wib.in", "r", stdin); freopen("wib.out", "w", stdout); #endif n = read(), d = read(); for (int i = 1; i <= n; ++i) sum ^= (a[i] = read()); std::sort(a + 1, a + n + 1); f[0][0] = 1; for (int i = 1; i <= n; ++i) { memcpy(tmp, f[d - 1], std::min((a[i] * 2 + 1), maxM) * sizeof(int)); for (int j = d - 1; j; --j) for (int k = 0; k < std::min(a[i] * 2, maxM); ++k) Mod(f[j][k] += f[j - 1][k ^ a[i]]); for (int k = 0; k < std::min(a[i] * 2, maxM); ++k) Mod(f[0][k] += tmp[k ^ a[i]]); } int ans = f[0][sum]; if (n % d == 0) --ans; printf("%d\n", (ans + mod) % mod); return 0; }
|