#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().unwrap() }; } fn main() { setup! { mut input: SplitWhitespace }; let n_0: usize = parse_next!(input); let mut i = 0; let mut n = n_0; let mut n_max = n_0; while n != 1 { match n % 2 { 0 => { n = n / 2; } 1 => { n = 3 * n + 1; } _ => unreachable!(), } if n > n_max { n_max = n; } i += 1; } let i_1 = i; println!("{}", i_1); println!("{}", n_max); }