結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー phspls
提出日時 2020-01-11 21:11:23
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 1,017 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,671 ms
コンパイル使用メモリ 189,892 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-20 11:12:07
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 86 WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io::Read;

fn solve(abc: Vec<f64>) {
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];
    if a == 0f64 {
        if b == 0f64 {
            if c == 0f64 {
                println!("{}", -1);
            } else {
                println!("{}", 0);
            }
        } else {
            println!("{}", 1);
            println!("{:.12}", -c / b);
        }
        return;
    }
    let temp = b * b - 4f64 * a * c;
    if temp > 0.0 {
        println!("{}", 2);
        println!("{:.12}", (-b - temp.powf(0.5)) / (2.0f64 * a));
        println!("{:.12}", (-b + temp.powf(0.5)) / (2.0f64 * a));
    } else if temp == 0.0 {
        println!("{}", 1);
        println!("{:.12}", -b / (2.0f64 * a));
    } else {
        println!("{}", 0);
    }
}

fn main() {
    let mut abc = String::new();
    std::io::stdin().read_to_string(&mut abc).ok();
    let abc: Vec<f64> = abc.trim().split('\n').next().unwrap().trim().split_whitespace().map(|i| i.parse::<f64>().unwrap()).collect();
    solve(abc);
}
0