use proconio::{fastout, input}; use reprol::math::radix::ToRadix; #[fastout] fn main() { input! { a: u64, b: u64, } for x in a..=b { if x % 3 == 0 || x.to_radix(10).contains(&3) { println!("{}", x); } } } #[allow(dead_code)] mod reprol { pub mod math { pub mod radix { pub trait ToRadix { fn to_radix(self, base: Self) -> Vec; } pub trait FromRadix { type Output; fn from_radix(&self, n: u32) -> Self::Output; } macro_rules! impl_integer { ($($ty:ident),*) => {$( impl ToRadix for $ty { fn to_radix(self, base: Self) -> Vec { if self == 0 { return vec![0]; } let mut n = self; let mut res = Vec::new(); while n > 0 { let x = (n % base) as u32; res.push(x); n /= base; } res.reverse(); res } } )*}; } impl_integer!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); impl FromRadix for String { type Output = u64; fn from_radix(&self, n: u32) -> Self::Output { u64::from_str_radix(self, n).unwrap() } } impl FromRadix for &str { type Output = u64; fn from_radix(&self, n: u32) -> Self::Output { u64::from_str_radix(self, n).unwrap() } } impl FromRadix for Vec { type Output = u64; fn from_radix(&self, n: u32) -> Self::Output { let n = n as u64; let mut res = 0; let mut base = 1; for &e in self.iter().rev() { res += e as u64 * base; base *= n; } res } } } } }