use std::io;
pub fn main() -> io::Result<()> {
let mut inp = String::new();
io::stdin().read_line(&mut inp)?;
let ints: Vec<i64> = inp.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
let [x,d,h,m] = ints[..] else {
panic!("Did not get 4 integers on input");
};
let mut res = 0;
res += (23 + x - d) * 24 * 60;
res += (23 - h) * 60;
res += 60 - m;
if x == 5 {
res += 24 * 60;
if d < 29 || (d == 29 && h < 2) {
res -= 60;
}
}
println!("{res}");
Ok(())
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | use std::io; pub fn main() -> io::Result<()> { let mut inp = String::new(); io::stdin().read_line(&mut inp)?; let ints: Vec<i64> = inp.trim().split_whitespace().map(|x| x.parse().unwrap()).collect(); let [x,d,h,m] = ints[..] else { panic!("Did not get 4 integers on input"); }; let mut res = 0; res += (23 + x - d) * 24 * 60; res += (23 - h) * 60; res += 60 - m; if x == 5 { res += 24 * 60; if d < 29 || (d == 29 && h < 2) { res -= 60; } } println!("{res}"); Ok(()) } |
English