Created
January 29, 2026 20:09
-
-
Save icub3d/f184ccfd8df6669efe57bcd5243b7289 to your computer and use it in GitHub Desktop.
Kattis sok
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{Read, stdin}; | |
| fn main() { | |
| let mut s = String::new(); | |
| stdin().read_to_string(&mut s).unwrap(); | |
| let mut ss = s.lines(); | |
| let have = ss | |
| .next() | |
| .unwrap() | |
| .split_whitespace() | |
| .map(|v| v.parse::<f64>().unwrap()) | |
| .collect::<Vec<_>>(); | |
| let want = ss | |
| .next() | |
| .unwrap() | |
| .split_whitespace() | |
| .map(|v| v.parse::<f64>().unwrap()) | |
| .collect::<Vec<_>>(); | |
| let factor = have | |
| .iter() | |
| .zip(want.iter()) | |
| .map(|(h, w)| h / w) | |
| .min_by(|a, b| a.partial_cmp(b).unwrap()) | |
| .unwrap(); | |
| println!( | |
| "{}", | |
| have.iter() | |
| .zip(want.iter()) | |
| .map(|(h, w)| format!("{:.6}", h - w * factor)) | |
| .collect::<Vec<_>>() | |
| .join(" ") | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment