結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-18 00:32:27 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 347 bytes |
| コンパイル時間 | 121 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-07-06 23:57:08 |
| 合計ジャッジ時間 | 12,053 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 73 WA * 49 |
コンパイルメッセージ
Main.rb:5: 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
p -1
exit
end
p 1
h = -c/b
h = 0 if h.abs < 1e-11
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
printf "%.15f\n", z+Math.sqrt(d)/2/a
end