Created
December 5, 2025 19:43
-
-
Save icub3d/df137c09757817e257107f61e5d95b49 to your computer and use it in GitHub Desktop.
Kattis temperature
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 (x, y) = s.trim().split_once(' ').unwrap(); | |
| let (x, y) = (x.parse::<f32>().unwrap(), y.parse::<f32>().unwrap()); | |
| // n = n*y + x | |
| // 0 = yn - n + x | |
| // n = x / (1-y) | |
| let d = 1. - y; | |
| let n = x / d; | |
| if d.abs() < 1e-6 { | |
| if x.abs() < 1e-6 { | |
| // 0/0 | |
| println!("ALL GOOD"); | |
| } else { | |
| // x/0 | |
| println!("IMPOSSIBLE"); | |
| } | |
| } else if n.fract().abs() < 1e-6 { | |
| println!("{}", n.round() as i32); | |
| } else { | |
| println!("{:.9}", n); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment