fn main() { const INF: usize = 1 << 60; input!{ n: usize, s: String, t: String, a: [usize; n], } // a_iの値集合を用意 let mut a_st = HashSet::new(); for &aa in &a { a_st.insert(aa); } // aがiの時の、s、tの組み合わせを調べる const CK_MAX : usize = 200_000; let mut cklist = vec![(INF, INF); CK_MAX + 9]; for &aa in &a { let s_mx = aa / s.len(); for s_cnt in (0..=s_mx).rev() { if ( aa - s.len() * s_cnt ) % t.len() == 0 { let t_cnt = ( aa - s.len() * s_cnt ) / t.len(); cklist[aa] = (s_cnt, t_cnt); break; } } } for &aa in &a { let (s_cnt, t_cnt) = cklist[aa]; for _i in 0..s_cnt { print!("{} ", &s); } for _i in 0..t_cnt { print!("{} ", &t); } println!(); } } // const MOD17: usize = 1000000007; // const MOD93: usize = 998244353; // let dx = vec![!0, 0, 1, 0]; // 上左下右 // let dy = vec![0, !0, 0, 1]; // 上左下右 // let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右 #[allow(unused)] use proconio::{input, marker::Chars, marker::Usize1}; #[allow(unused)] use std::{ mem::swap, cmp::min, cmp::max, cmp::Reverse, collections::HashSet, collections::BTreeSet, collections::HashMap, collections::BTreeMap, collections::BinaryHeap, collections::VecDeque, iter::FromIterator, };