結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー りあん
提出日時 2019-12-18 00:24:55
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 655 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 416 ms
コンパイル使用メモリ 41,844 KB
最終ジャッジ日時 2026-02-22 05:00:21
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 81 WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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 if (p>0) printf("2\n%.16Lf\n%.16Lf\n", -0.5*(sqrtl(p) + b) / a, (sqrtl(p) - b)*0.5 / a);
    else puts("0");
  }
  else{
    if (b) printf("1\n%.16Lf\n", -c / (long double)b);
    else puts(c ? "0" : "-1");
  }
  return 0;
}
0