結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-01 23:47:13 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,705 bytes |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 32,128 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-22 17:25:12 |
| 合計ジャッジ時間 | 3,127 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
long long D;
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);
}
if (b%2 == 0) {
D = (long long)(b/2)*(b/2) - (long long)a*c;
if (D > 0) {
s1 = -(double)(b/2)/a - sqrt(D)/a;
s2 = -(double)(b/2)/a + sqrt(D)/a;
logging(2, s1, s2);
} else if (D == 0) {
s1 = (double)-(b/2)/a;
logging(1, s1, 0);
} else {
logging(0, 0, 0);
}
}
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;
}