complete 2805.rs 4366.rs 6235.rs 31614.rs 34412.rs

This commit is contained in:
2026-03-30 03:10:37 +09:00
parent 5c6ad569c4
commit c85e661c6c
5 changed files with 148 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
use std::io::stdin;
fn main() {
let mut line = String::new();
let mut distance = 0;
let mut before_time = 0;
let mut speed = 0;
loop {
line.clear();
stdin().read_line(&mut line).unwrap();
if line.trim().is_empty() {
break;
}
let mut iter = line.trim().split(' ');
let mut time_str = iter.next().unwrap().split(':');
let (h, m, s) = (
time_str.next().unwrap().parse::<u64>().unwrap(),
time_str.next().unwrap().parse::<u64>().unwrap(),
time_str.next().unwrap().parse::<u64>().unwrap(),
);
let time = h * 3600 + m * 60 + s;
distance = distance + speed * (time - before_time);
if let Some(spd_str) = iter.next() {
speed = spd_str.parse::<u64>().unwrap();
} else {
println!(
"{:02}:{:02}:{:02} {:.2} km",
h,
m,
s,
distance as f64 / 3600f64
);
}
before_time = h * 3600 + m * 60 + s;
}
}