結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
tamaron
|
| 提出日時 | 2019-12-18 14:45:34 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 332 bytes |
| コンパイル時間 | 258 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-07-07 00:44:54 |
| 合計ジャッジ時間 | 11,868 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 56 WA * 66 |
コンパイルメッセージ
Main.rb:3: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:12: 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
puts -1
elsif a==0
puts 1
puts -c.to_f/b
else
if b*b-4*a*c<0
puts 0
elsif b*b-4*a*c==0
puts 1
puts -b.to_f/2*a
else
puts 2
puts (-b.to_f+(b*b-4*a*c)**(1/2.0))/2*a
puts (-b.to_f-(b*b-4*a*c)**(1/2.0))/2*a
end
end
tamaron