結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2019-12-18 01:00:41 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 31,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 22:00:36 |
合計ジャッジ時間 | 3,375 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 122 |
ソースコード
#include<stdio.h> #include<assert.h> #include<math.h> int main(){ long long a, b, c; scanf("%lld%lld%lld", &a, &b, &c); if (a){ if (a < 0){ a = -a; b = -b; c = -c; } long long p = b*b-a*c*4; if (!p) printf("1\n%.14Lf\n", -b*0.5l / a); else if (p>0) { long double s, t; if (b >= 0) { s = -0.5*(sqrtl(p) + b) / a; t = c / (long double)a / s; } else { t = (sqrtl(p) - b)*0.5 / a; s = c / (long double)a / t; } printf("2\n%.14Lf\n%.14Lf\n", s, t); } else puts("0"); } else{ if (b) printf("1\n%.14Lf\n", -c / (long double)b); else puts(c ? "0" : "-1"); } return 0; }