結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
|
提出日時 | 2019-12-18 00:41:31 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 382 bytes |
コンパイル時間 | 107 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-07-06 23:59:33 |
合計ジャッジ時間 | 12,515 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 66 WA * 25 RE * 31 |
コンパイルメッセージ
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 abort else p 2 printf "%.15f\n", z-Math.sqrt(d)/2/a.abs printf "%.15f\n", z+Math.sqrt(d)/2/a.abs end