https://atcoder.jp/contests/abc263/tasks/abc263_c
combinationsを使うだけですね。
// Monotonically Increasing #![allow(non_snake_case)] use itertools::Itertools; fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } fn join<T :std::string::ToString>(v: Vec<T>) -> String { v.iter().map(|c| c.to_string()).collect::<Vec::<String>>().join(" ") } //////////////////// process //////////////////// fn main() { let v = read_vec(); let N: usize = v[0]; let M: usize = v[1]; for v in (1..(M+1)).combinations(N) { println!("{}", join(v)) } }