結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
|
提出日時 | 2019-12-18 00:37:52 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 374 bytes |
コンパイル時間 | 64 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-07-06 23:58:30 |
合計ジャッジ時間 | 12,018 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 93 WA * 29 |
コンパイルメッセージ
Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
def lscan; gets.split.map(&:to_f); end a,b,c = lscan if a == 0 if b == 0 if c == 0 p -1 else p 0 end exit end p 1 h = -c/b printf "%.15f\n", h exit end d = b*b-4*a*c z = -b/2/a if d < 0 p 0 elsif d == 0 p 1 printf "%.15f\n", z else p 2 printf "%.15f\n", z-Math.sqrt(d)/2/a.abs printf "%.15f\n", z+Math.sqrt(d)/2/a.abs end