#![allow(dead_code, unused_mut)] #![allow(non_snake_case)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } struct Combination { MOD: u64, size: usize, fact: Vec, inv_fact: Vec, } impl Combination { fn new(size: usize, _MOD: u64) -> Self { let mut fact = vec![1; size + 1]; let mut inv_fact = vec![1; size + 1]; for i in 1..size + 1 { fact[i] = fact[i - 1] * i as u64 % _MOD; } inv_fact[size] = Self::modpow(fact[size], _MOD - 2, _MOD); for i in (1..size + 1).rev() { inv_fact[i - 1] = inv_fact[i] * i as u64 % _MOD; } Combination { MOD: _MOD, size, fact, inv_fact, } } fn modpow(mut x: u64, mut y: u64, m: u64) -> u64 { let mut res: u64 = 1; while y > 0 { if y & 1 > 0 { res = res * x % m; } x = x * x % m; y >>= 1; } res } fn modinv(x: u64, m: u64) -> u64 { Self::modpow(x, m - 2, m) } fn nPr(&self, n: usize, r: usize) -> u64 { if n < r { return 0; }; self.fact[n] * self.inv_fact[n - r] % self.MOD } fn nCr(&self, n: usize, r: usize) -> u64 { if n < r { return 0; }; self.fact[n] * self.inv_fact[r] % self.MOD * self.inv_fact[n - r] % self.MOD } } const MOD: u64 = 998244353; fn main() { input!{ n:usize, k:usize, a:[u32; n] } // println!("{:?}", sw); let ncr = Combination::new(n, MOD); let mut ans = 0; let mut cur = 0; let mut r = 0; for l in 0..n { if l >= r { cur = a[l]; r = l + 1; } while r < n && cur & a[r] == 0 { cur |= a[r]; r += 1; } if r - l >= k { ans = (ans + ncr.nCr(r - l - 1, k - 1)) % MOD; } cur ^= a[l]; } println!("{}", ans); }