use std::io::Write; fn run() { let m = 2000000usize; let mut cnt = vec![0u32; m + 1]; let mut fact = vec![1u32; m + 1]; let mut ifact = vec![1u32; m + 1]; for i in 1..=m { let k = i.trailing_zeros(); cnt[i] = cnt[i - 1] + k; fact[i] = fact[i - 1] * (i as u32 >> k); } let mut t = 1; let mut r = fact[m]; let mut n = (1u64 << 31) - 1; while n > 0 { if n & 1 == 1 { t = t * r; } r = r * r; n >>= 1; } ifact[m] = t; for i in (1..m).rev() { ifact[i] = ifact[i + 1] * ((i + 1) as u32 >> (i + 1).trailing_zeros()); } let binom = |a: usize, b: usize| -> u32 { if a < b { 0 } else { let c = cnt[a] - cnt[b] - cnt[a - b]; let v = fact[a] * ifact[b] * ifact[a - b]; if c >= 32 { 0 } else { v << c } } }; input! { t: usize, ask: [(usize, usize, usize); t], } let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); for (a, b, c) in ask { let ans = if c % 2 == 0 { 0 } else { let n = binom(b + c - 1, b) as usize * c + a - 1; if !n & a > 0 { 0 } else { 1 } }; writeln!(out, "{}", ans).ok(); } } fn main() { run(); } // ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let 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_export] 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_export] 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, bytes) => { read_value!($iter, String).bytes().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ----------