use std::io::Read; fn fill(k: usize, a: &[usize], cond: &mut [usize]) { if a.len() <= 1 { return; } let mut split = 0; for i in 1..a.len() { let p = (a[i - 1] >> k) & 1; let q = (a[i] >> k) & 1; if p == 0 && q == 1 { cond[k] &= 1; split = i; } if p == 1 && q == 0 { cond[k] &= 2; split = i; } } if k == 0 { if a.len() > 2 || split != 1 { cond[k] = 0; } return; } if cond[k] == 3 { fill(k - 1, a, cond); } else if cond[k] != 0 { fill(k - 1, &a[..split], cond); fill(k - 1, &a[split..], cond); } } fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n: usize = it.next().unwrap().parse().unwrap(); let l: usize = it.next().unwrap().parse().unwrap(); let r: usize = it.next().unwrap().parse().unwrap(); let a: Vec = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect(); let bit = 61; let mut cond = vec![3; bit]; fill(bit - 1, &a, &mut cond); if cond.contains(&0) { println!("0"); return; } let mut dp = [[0usize; 2]; 2]; dp[0][0] = 1; for k in (0..bit).rev() { let mut next = [[0; 2]; 2]; let l = (l >> k) & 1; let r = (r >> k) & 1; for i in 0..2 { for j in 0..2 { //0 if cond[k] & 1 != 0 && (i > 0 || l == 0) { next[i][j | r] += dp[i][j]; } //1 if cond[k] & 2 != 0 && (j > 0 || r == 1) { next[i | (l ^ 1)][j] += dp[i][j]; } } } dp = next; } let mut ans = 0; for i in 0..2 { for j in 0..2 { ans += dp[i][j]; } } println!("{}", ans); } fn main() { run(); }