use std::io::{stdout, BufReader, BufWriter, Read, Write}; #[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = Read::bytes(BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[allow(unused_macros)] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[allow(unused_macros)] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } fn main() { let out = stdout(); let mut writer = BufWriter::new(out.lock()); solve(&mut writer); writer.flush().unwrap(); } fn solve(mut writer: W) { #[allow(unused_macros)] macro_rules! print { ($fmt:expr) => { write!(writer, $fmt).unwrap() }; ($fmt:expr, $($arg:tt)*) => { write!(writer, $fmt, $($arg)*).unwrap() }; } #[allow(unused_macros)] macro_rules! println { ($fmt:expr) => { writeln!(writer, $fmt).unwrap() }; ($fmt:expr, $($arg:tt)*) => { writeln!(writer, $fmt, $($arg)*).unwrap() }; } // Main Code input! { n: usize, a: usize, x: [usize; n] } let M = 1000000007; let size = 100 * n + 1; let mut dp = vec![vec![0 as usize; size]; n + 1]; dp[0][0] = 1; for i in 0..n { let mut newdp = vec![vec![0; size]; n + 1]; for j in 0..=n { for k in 0..size { if j > 0 && k >= x[i] { newdp[j][k] = dp[j][k] + dp[j - 1][k - x[i]]; } else { newdp[j][k] = dp[j][k]; } newdp[j][k] %= M; } } dp = newdp; } let mut ans = 0 as usize; for i in 1..=n { if i * a >= size { break; } for b in i * a .. size { ans += dp[i][b]; ans %= M; } } println!("{}", ans); }