#include #include #include #define DEBUG true #define $(x) {if (DEBUG) {std::cout << "(line " << __LINE__ << ") "; {x} std::cout << std::endl;}} #define _(x) {std::cout << #x << " = " << x << " ";} int main() { int N, K; std::cin >> N >> K; std::vector arr(N, 0); int haha = 0; int total = 0; for (int i = 0; i < N; i++) { std::cin >> arr[i]; } int last = -1; for (int start = 0; start < N; start++) { haha = 0; for (int end = start; end < N; end++) { haha = haha | arr[end]; // std::cout << "start: " << start << ", end: " << end << ", sum: " << sum << ", or: " << haha << " (" << (bool) (K == haha && sum >= K) << ")\n"; if (K == haha) { if (last > end) { total += last - end; break; } else { total++; } } if (haha > K) { // total += N - end; last = end; break; // total++; } } } std::cout << total << "\n"; return 0; }