#[macro_use] #[allow(dead_code, unused_macros, non_upper_case_globals)] mod cp_io { pub const ENABLE_DUMP: bool = true; pub const PRECISION: usize = 10; macro_rules! p { ($x: expr) => { $x.print(); print!("\n"); }; ($x: expr, $($y: expr),+) => { { $x.print(); print!(" "); p!($($y),+); } }; } macro_rules! pf { ($($x: expr),+) => { { use std::io::*; p!($($x),+); stdout().flush().unwrap(); } }; } macro_rules! d { ($($a: expr),+) => { if ENABLE_DUMP { use std::io::*; write!(stderr(), "{}:{}\t", file!(), line!()).unwrap(); d!(A $($a),+); write!(stderr(), " = ").unwrap(); d!(B $($a),+); write!(stderr(), "\n").unwrap(); stderr().flush().unwrap(); } }; (A $x: expr) => { write!(stderr(), "{}", stringify!($x)).unwrap(); }; (A $x: expr, $($y: expr),+) => { write!(stderr(), "{}, ", stringify!($x)).unwrap(); d!(A $($y),+); }; (B $x: expr) => { write!(stderr(), "{:?}", $x).unwrap(); }; (B $x: expr, $($y: expr),+) => { write!(stderr(), "{:?}, ", $x).unwrap(); d!(B $($y),+); }; } pub trait Print { fn print(&self); } macro_rules! print_normal { ($t: ty) => { impl Print for $t { fn print(&self) { print!("{}", self); } } }; ($t: ty, $($u: ty),+) => { print_normal!($t); print_normal!($($u),+); }; } macro_rules! print_float { ($t: ty) => { impl Print for $t { fn print(&self) { print!("{:.*}", PRECISION, self); } } }; ($t: ty, $($u: ty),+) => { print_float!($t); print_float!($($u),+); }; } print_normal!(u8, u16, u32, u64, usize); print_normal!(i8, i16, i32, i64, isize); print_normal!(bool, String); print_float!(f32, f64); pub trait Scan { fn scan() -> T; } macro_rules! scan_primitive { ($t: ty) => { impl Scan<$t> for $t { fn scan() -> $t { get_word().expect("EOF?").parse() .unwrap_or_else(|e| panic!("Cannot parse {}", e)) } } }; ($t: ty, $($u: ty),+) => { scan_primitive!($t); scan_primitive!($($u),+); }; } macro_rules! scan_tuple { ($($t: ident),*) => { impl< $($t: Scan<$t>),* > Scan< ( $($t),* ) > for ( $($t),* ) { fn scan() -> ( $($t),* ) { ( $( $t::scan()),* ) } } }; } scan_primitive!(u8, u16, u32, u64, usize); scan_primitive!(i8, i16, i32, i64, isize); scan_primitive!(bool, String); scan_tuple!(A, B); scan_tuple!(A, B, C); scan_tuple!(A, B, C, D); pub fn get>() -> T { T::scan() } pub fn get_vec>(n: usize) -> Vec { (0..n).map(|_| get()).collect() } pub fn get_mat>(r: usize, c: usize) -> Vec> { (0..r).map(|_| get_vec(c)).collect() } pub fn get_vec_char() -> Vec { get_word().unwrap().chars().collect() } pub fn get_mat_char(h: usize) -> Vec> { (0..h).map(|_| get_vec_char()).collect() } pub fn get_line() -> String { get_line_wrapped().unwrap() } fn get_word() -> Option { let mut res = String::with_capacity(16); while let Some(c) = get_u8() { let d = c as char; if !d.is_whitespace() { res.push(d); } else if res.len() != 0 { unget_u8(c); break; } } if res.len() == 0 { None } else { Some(res) } } pub fn get_line_wrapped() -> Option { let c = get_u8(); if c.is_none() { return None; } let mut line = String::with_capacity(20); line.push(c.unwrap() as char); loop { let c = get_u8(); if c.is_none() || c.unwrap() == b'\n' { // コメントはC++等での仕様 // if c.is_some() { // self.unget_u8(b'\n'); // } return Some(line); } line.push(c.unwrap() as char); } } static mut idx: usize = 0; static mut len: usize = 0; static mut buf: [u8; 65536] = [0; 65536]; fn get_u8() -> Option { unsafe { use std::io::{stdin, Read}; if idx == len { match stdin().read(&mut buf) { Ok(l) if l > 0 => { idx = 0; len = l; } _ => return None, } } idx += 1; Some(buf[idx - 1]) } } fn unget_u8(c: u8) { unsafe { idx -= 1; buf[idx] = c; } } pub fn has_next() -> bool { loop { let c = get_u8(); if c.is_none() { return false; } let c = c.unwrap(); if !(c as char).is_whitespace() { unget_u8(c); return true; } } } } fn main() { let thd = std::thread::Builder::new().stack_size(104_857_600); // 100 MB thd.spawn(solver::solve).unwrap().join().unwrap(); } #[allow(unused_imports)] mod solver { use std::*; use std::collections::*; use cp_io::*; pub fn solve() { // solution here pf!(0, 0); let d1: i64 = get(); if d1 == 0 { return; } pf!(d1, 0); let d2: i64 = get(); if d2 == 0 { return; } pf!(d1 - d2 / 2, d2 / 2); } }