use std::io; use std::io::prelude::*; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let mut lines = input.lines(); // Read N and Q let first_line = lines.next().unwrap(); let mut first_line_parts = first_line.split_whitespace(); let n: usize = first_line_parts.next().unwrap().parse().unwrap(); let q: usize = first_line_parts.next().unwrap().parse().unwrap(); // Read array A let second_line = lines.next().unwrap(); let a: Vec = second_line.split_whitespace() .map(|s| s.parse().unwrap()) .collect(); // Process each query for _ in 0..q { let query_line = lines.next().unwrap(); let mut query_parts = query_line.split_whitespace(); let l: usize = query_parts.next().unwrap().parse().unwrap(); let r: usize = query_parts.next().unwrap().parse().unwrap(); let k: i32 = query_parts.next().unwrap().parse().unwrap(); let mut ans = 0; for ind in (l-1)..r { if a[ind] % k == 0 { ans += 1; } } println!("{}", ans); } }