#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); } } size_t left = 0; size_t right = 0; size_t count = 0; for(left = 0; left < N; left++) { for(right = left; right < N; right++) { if(days[right] & (~K)) { //std::cout << "called, days[right]:" << days[right] << std::endl; break; } if(seqCheck(left, right, days, K)) { // std::cout << "seq is correct, " << left << " to " << right << std::endl; count++; } } } std::cout << count << std::endl; return 0; }