#![allow(non_snake_case)] #[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut tokens = $s.split_whitespace(); input_inner! { tokens, $($r)* } }; ($($r:tt)*) => { let s = { use std::io::Read; let mut res = String::new(); ::std::io::stdin().read_to_string(&mut res).unwrap(); res }; let mut tokens = s.split_whitespace(); input_inner! { tokens, $($r)* } }; } #[allow(unused_macros)] macro_rules! input_inner { ($tokens:expr) => {}; ($tokens:expr,) => {}; ($tokens:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($tokens, $t); input_inner! { $tokens $($r)* } }; } #[allow(unused_macros)] macro_rules! read_value { ($tokens:expr, ( $($t:tt),* )) => { ( $(read_value!($tokens, $t)),* ) }; ($tokens:expr, [ $t:tt; $len:expr ]) => { (0..$len).map(|_| read_value!($tokens, $t)).collect::>() }; ($tokens:expr, chars) => { read_value!($tokens, String).chars().collect::>() }; ($tokens:expr, usize1) => { read_value!($tokens, usize) - 1 }; ($tokens:expr, $t:ty) => { $tokens.next().unwrap().parse::<$t>().expect("parse error") }; } use std::iter::{ FromIterator }; fn modulo(lhs: i64, rhs: i64) -> i64 { assert!(rhs > 0); let r = lhs % rhs; if r >= 0 { r } else { r + rhs } } fn main() { input! { A: i64, B: i64, S: chars, } assert_eq!(S[..3].iter().collect::(), "UTC"); let sign = match S[3] { '+' => 1, '-' => -1, _ => panic!(), }; let s_diff = String::from_iter(S[4..].iter()); let mut it = s_diff.split('.'); let x: i64 = it.next().unwrap().parse().unwrap(); let y: i64 = match it.next() { Some(s) => s.parse().unwrap(), None => 0, }; let now = 60*A + B - 9*60; // UTC, 分単位 let diff = sign * (60*x + 6*y); // 分単位 let ans = modulo(now+diff, 24*60); let ans_h = ans / 60; let ans_m = ans % 60; println!("{:02}:{:02}", ans_h, ans_m); }