結果

問題 No.955 ax^2+bx+c=0
ユーザー りあんりあん
提出日時 2019-12-18 00:21:00
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 569 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 23:41:50
合計ジャッジ時間 6,463 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54 WA * 24 RE * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<assert.h>
#include<math.h>
int main(){
  long long a, b, c;
  long double p;
  scanf("%lld%lld%lld", &a, &b, &c);
  if (a){
    if (a > 0){
      a = -a;
      b = -b;
      c = -c;
    }
    p = b*(long double)b - a*(long double)c*4;
    if (fabsl(p)<1e-12) printf("1\n%.16f\n", -b*0.5 / a);
    else if (p>0) printf("2\n%.16Lf\n%.16Lf\n", (sqrtl(p) - b)*0.5 / a, -0.5*(sqrtl(p) + b) / a);
    else puts("0");
  }
  else{
    assert(0);
    if (b) printf("1\n%.16Lf\n", -c / (long double)b);
    else puts(c ? "0" : "-1");
  }
  return 0;
}
0