結果

問題 No.955 ax^2+bx+c=0
ユーザー simansiman
提出日時 2022-09-14 02:26:57
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 308 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-12-14 10:37:40
合計ジャッジ時間 14,882 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46 WA * 76
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

A, B, C = gets.split.map(&:to_i)

if A == 0
  puts -1
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
    puts "%.12f" % Rational(-B - Math.sqrt(e), 2 * A)
    puts "%.12f" % Rational(-B + Math.sqrt(e), 2 * A)
  end
end
0