結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2019-12-18 01:58:09 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 652 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-09-18 22:04:50 |
合計ジャッジ時間 | 12,977 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 122 |
コンパイルメッセージ
Main.rb:18: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
def h(x,y) puts (x<0?y<0?'':?-:y<0??-:'')+(?0*100+"#{x.abs/y.abs}").sub(/.{100}$/){".#$&"}.sub(/^0*\B/){''} end def f(x,y) h(x*10**100,y) end def g(x,y,z) t=(0..10**200).bsearch{|t|t*t>=10**200*y.abs} h(x*10**100+(y<0?-1:1)*t,z) end a,b,c=gets.split.map &:to_i if a==0 if b==0 if c==0 p -1 else p 0 end else p 1 f(-c,b) end else d=b*b-4*a*c if d>0 p 2 if a>0 g(-b,-d,2*a) g(-b,d,2*a) else g(-b,d,2*a) g(-b,-d,2*a) end elsif d==0 p 1 f(-b,2*a) else p 0 end end