結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
|
提出日時 | 2020-01-01 23:23:51 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,319 bytes |
コンパイル時間 | 325 ms |
コンパイル使用メモリ | 31,744 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-22 17:24:27 |
合計ジャッジ時間 | 3,683 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 90 WA * 32 |
ソースコード
#include <stdio.h> #include <stdlib.h> #include <math.h> void logging(int n, double x1, double x2) { printf("%d\n", n); if (n == 1) { printf("%.15lf\n", x1); } else if (n == 2) { printf("%.15lf\n%.15lf\n", x1, x2); } exit(EXIT_SUCCESS); } int main(void) { long a, b, c; double s1, s2; scanf("%ld%ld%ld", &a, &b, &c); if (a == 0) { if (b == 0) { if (c == 0) { logging(-1, 0, 0); } logging(0, 0, 0); } s1 = (double)-c/b; logging(1, s1, 0); } if (a == b && b == c) { logging(0, 0, 0); } if (b == 0) { if (c == 0) { logging(1, 0, 0); } s1 = sqrt(-(double)c/a); s2 = -s1; logging(2, s1, s2); } if (c == 0) { s1 = 0; s2 = -(double)b/a; if (s1 < s2) { logging(2, s1, s2); } logging(2, s2, s1); } long long D = (long long)b*b - (long long)4*a*c; if (D > 0) { s1 = (double)-b/(2*a) - sqrt(D)/(2*a); s2 = (double)-b/(2*a) + sqrt(D)/(2*a); logging(2, s1, s2); } else if (D == 0) { s1 = (double)-b/(2*a); logging(1, s1, 0); } else { logging(0, 0, 0); } return EXIT_SUCCESS; }