/* -*- coding: utf-8 -*- * * 1072.cc: No.1072 A Nice XOR Pair - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], cs[MAX_N]; /* subroutines */ /* main */ int main() { int n, x; scanf("%d%d", &n, &x); for (int i = 0; i < n; i++) scanf("%d", as + i); sort(as, as + n); int m = 0; for (int i = 0; i < n;) { int j = i + 1; while (j < n && as[i] == as[j]) j++; as[m] = as[i], cs[m] = j - i; m++; i = j; } //for (int i = 0; i < m; i++) printf("%d:%d ", as[i], cs[i]); putchar('\n'); ll sum = 0; for (int i = 0; i < m; i++) { if (x == 0) sum += (ll)cs[i] * (cs[i] - 1) / 2; else { int b = as[i] ^ x; int j = lower_bound(as, as + m, b) - as; if (j < i && as[j] == b) sum += (ll)cs[i] * cs[j]; } } printf("%lld\n", sum); return 0; }