結果

問題 No.955 ax^2+bx+c=0
ユーザー shoooooshooooo
提出日時 2020-01-01 17:47:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-22 11:50:10
合計ジャッジ時間 6,755 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 122
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
a,b,c=map(int,input().split())
if a!=0:
  if b**2-4*a*c<0:
    print(0)
  elif b**2-4*a*c==0:
    print(1)
    print((-b-math.sqrt(b**2-4*a*c))/(2*a))
  else:
    x1=(-b-math.sqrt(b**2-4*a*c))/(2*a)
    x2=(-b+math.sqrt(b**2-4*a*c))/(2*a)
    if b>0:
      x2=c/a/x1
    elif b<0:
      x1=c/a/x2
    x1,x2=min(x1,x2),max(x1,x2)
    print(2)
    print(x1)
    print(x2)
else:
  if b==0:
    if c==0:
      print(-1)
    else:
      print(0)
  else:
    print(1)
    print(-c/b)
0