結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-09-14 02:33:59 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 453 bytes |
| コンパイル時間 | 182 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-12-14 10:46:08 |
| 合計ジャッジ時間 | 14,443 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 97 WA * 25 |
コンパイルメッセージ
Main.rb:4: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
A, B, C = gets.split.map(&:to_i)
if A == 0 && B == 0 && C == 0
puts -1
elsif A == 0 && B == 0
puts 0
elsif A == 0
puts 1
puts "%.12f" % Rational(-C, B)
else
e = B ** 2 - 4 * A * C
if e == 0
puts 1
puts "%.12f" % Rational(-B, 2 * A)
elsif e < 0
puts 0
else
puts 2
x = Rational(-B - Math.sqrt(e), 2 * A)
y = Rational(-B + Math.sqrt(e), 2 * A)
puts "%.12f" % [x, y].min
puts "%.12f" % [x, y].max
end
end
siman