結果
| 問題 |
No.1179 Quadratic Equation
|
| コンテスト | |
| ユーザー |
ixTL255
|
| 提出日時 | 2023-01-08 22:09:36 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 704 bytes |
| コンパイル時間 | 22,597 ms |
| コンパイル使用メモリ | 391,416 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 01:58:12 |
| 合計ジャッジ時間 | 14,830 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
コンパイルメッセージ
warning: variable does not need to be mutable --> src/main.rs:9:9 | 9 | let mut d = b * b - 4 * a * c; | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
ソースコード
fn main() {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
let mut itr = s.trim().split_whitespace();
let a: i32 = itr.next().unwrap().parse().unwrap();
let b: i32 = itr.next().unwrap().parse().unwrap();
let c: i32 = itr.next().unwrap().parse().unwrap();
let mut d = b * b - 4 * a * c;
if d < 0 { println!("imaginary"); }
else if d == 0 { println!("{}", -b as f64 / (2. * a as f64)); }
else {
let d = (d as f64).sqrt();
let mut ans: Vec<f64> = vec![(-b as f64 - d) / (2. * a as f64), (-b as f64 + d) / (2. * a as f64)];
ans.sort_by(|a, b| a.partial_cmp(b).unwrap());
println!("{} {}", ans[0], ans[1]);
}
}
ixTL255