結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2019-12-18 12:52:14 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,103 bytes |
| コンパイル時間 | 11,483 ms |
| コンパイル使用メモリ | 402,188 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 00:41:30 |
| 合計ジャッジ時間 | 14,026 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 108 WA * 14 |
ソースコード
use std::io::Read;
fn run() {
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).unwrap();
let mut it = s.trim().split_whitespace();
let mut a: i64 = it.next().unwrap().parse().unwrap();
let mut b: i64 = it.next().unwrap().parse().unwrap();
let mut c: i64 = it.next().unwrap().parse().unwrap();
if a == 0 {
if b == 0 {
if c == 0 {
println!("-1");
} else {
println!("0");
}
} else {
let ans = -c as f64 / b as f64;
println!("1\n{:.12}", ans);
}
return;
}
let d = b * b - 4 * a * c;
if d < 0 {
println!("0");
return;
}
if d == 0 {
let ans = -b as f64 / (2 * a) as f64;
println!("1\n{:.12}", ans);
return;
}
if a < 0 {
a *= -1;
b *= -1;
c *= -1;
}
let x = (-b as f64 - (d as f64).sqrt()) / (2 * a) as f64;
let y = (2 * c) as f64 / (-b as f64 - (d as f64).sqrt());
println!("2\n{:.12}\n{:.12}", x, y);
}
fn main() {
run();
}
akakimidori