結果

問題 No.1179 Quadratic Equation
ユーザー 小野寺健小野寺健
提出日時 2021-11-02 14:25:04
言語 Ruby
(3.3.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-19 22:41:18
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
12,160 KB
testcase_01 AC 77 ms
12,160 KB
testcase_02 AC 77 ms
12,160 KB
testcase_03 AC 77 ms
12,032 KB
testcase_04 AC 76 ms
12,160 KB
testcase_05 AC 78 ms
12,160 KB
testcase_06 AC 78 ms
12,160 KB
testcase_07 AC 78 ms
12,416 KB
testcase_08 AC 76 ms
12,160 KB
testcase_09 AC 77 ms
12,160 KB
testcase_10 AC 78 ms
12,288 KB
testcase_11 AC 77 ms
12,416 KB
testcase_12 AC 78 ms
12,160 KB
testcase_13 AC 78 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a, b, c = gets.split(" ").map{|s| s.to_i}

d2 = b**2 - 4*a*c

if d2 < 0 then
	puts "imaginary"
elsif d2 == 0 then
	a0 = -b/(2*a)
	puts a0
else
	d = Math.sqrt(d2)
	a0 = (-b-d)/(2*a)
	a1 = (-b+d)/(2*a)
	a0, a1 = a1, a0 if a0 > a1
	puts "#{a0} #{a1}"
end
0