結果

問題 No.1179 Quadratic Equation
ユーザー StrorkisStrorkis
提出日時 2020-08-21 22:27:36
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 12,953 ms
コンパイル使用メモリ 400,884 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 05:55:00
合計ジャッジ時間 13,642 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let (a, b, c): (i32, i32, i32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let d = b * b - 4 * a * c;
    if d > 0 {
        let x = (-(b as f64) - (d as f64).sqrt()) / (2.0 * (a as f64));
        let y = (-(b as f64) + (d as f64).sqrt()) / (2.0 * (a as f64));
        if x < y {
            println!("{:.10} {:.10}", x, y);
        } else {
            println!("{:.10} {:.10}", y, x);
        }
    } else if d == 0 {
        println!(
            "{:.10}",
            (-(b as f64) / (2.0 * (a as f64))),
        )
    } else {
        println!("imaginary");
    }
}
0