結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2019-12-18 12:45:00 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 722 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 30,848 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 00:40:53 |
合計ジャッジ時間 | 2,859 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 71 WA * 51 |
ソースコード
// yuki 955 ax^2+bx+c=0 // 2019.12.18 bal4u #include <stdio.h> #include <math.h> typedef long long ll; int main() { int a, b, c; long double x1, x2; scanf("%d%d%d", &a, &b, &c); if (a == 0) { if (b == 0 && c == 0) puts("-1"); else if (b == 0) puts("0"); else { puts("1"); printf("%.16lf\n", -(double)c/b); } } else { ll d = (ll)b*b - 4*(ll)a*c; long double t; if (d < 0) puts("0"); else if (d == 0) { puts("2"); t = -(long double)b/(2*a); printf("%.16Lf\n%.16Lf\n", t, t); } else { t = d; t = sqrtl(t); puts("2"); x1 = (-b-t)/(2*a), x2 = (-b+t)/(2*a); if (x1 <= x2) printf("%.16Lf\n%.16Lf\n", x1, x2); else printf("%.16Lf\n%.16Lf\n", x2, x1); } } return 0; }