結果

問題 No.1179 Quadratic Equation
ユーザー otamay6otamay6
提出日時 2020-08-21 22:04:07
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 248 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-23 05:53:31
合計ジャッジ時間 1,999 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
12,288 KB
testcase_01 AC 97 ms
12,288 KB
testcase_02 AC 92 ms
12,160 KB
testcase_03 AC 92 ms
12,160 KB
testcase_04 AC 88 ms
12,160 KB
testcase_05 AC 91 ms
12,288 KB
testcase_06 AC 89 ms
12,416 KB
testcase_07 AC 89 ms
12,160 KB
testcase_08 AC 87 ms
12,416 KB
testcase_09 AC 89 ms
12,288 KB
testcase_10 WA -
testcase_11 AC 90 ms
12,160 KB
testcase_12 AC 90 ms
12,288 KB
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:12: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

a,b,c = gets.split.map(&:to_i)

d =b*b - 4*a*c
if  d< 0 then
    puts "imaginary"
    return
end
a= a.to_f
b=b.to_f
c=c.to_f
if d==0 then
    puts -b/(2*a)
    return
end
d = Math.sqrt(d.to_f)
x1 = (-b+d)/(2*a)
x2 = (-b-d)/(2*a)

puts "#{x2} #{x1}"
0