#include #include bool seqCheck(int left, int right, const std::vector &seq, int bullCost) { int sumOR = 0; for(int i = left; i <= right; i++) { sumOR |= seq[i]; } //std::cout << "sum or: " << seq[left] << std::endl; return bullCost == sumOR; } int main() { int N, K; if(scanf("%d %d", &N, &K)!=2) std::cout << "wtf "<< std::endl; std::vector days(N); for(int i = 0; i < N; i++) { int tmp; if(scanf("%d", &tmp)==1) { // std::cout << "got: " << tmp << std::endl; days[i] =(tmp); } } std::vectorprikol (N); int pos = N; for (int i = N - 1; i >= 0; --i) { if(days[i] & (~K)) { pos = i; } prikol[i] = pos; } size_t left = 0; size_t right = 0; size_t count = 0; for(left = 0; left < N; left++) { int sumOR = 0; for(right = left; right < prikol[left]; right++) { sumOR |= days[right]; if(sumOR == K) { // std::cout << "seq is correct, " << left << " to " << right << std::endl; count+= prikol[right] - right; break; } } } std::cout << count << std::endl; return 0; }