結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-18 03:43:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 787 bytes |
| コンパイル時間 | 1,148 ms |
| コンパイル使用メモリ | 31,360 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 00:25:36 |
| 合計ジャッジ時間 | 6,315 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 81 RE * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%lld%lld%lld", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <math.h>
#include <assert.h>
int main() {
long long int a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a == 0) {
if (b == 0) {
if (c == 0) printf("-1\n");
else printf("0\n");
}
else printf("1\n%.20lf\n", (double)((long double)c / (long double) -b));
}
else {
long double ta(a), tb(b), tc(c), d, sa, sb;
d = b * b - 4 * a * c;
d = sqrtl(d);
if (b * b - 4 * a * c > 0) {
assert(0);
sa = (-tb + d) / ta / 2;
sb = (-tb - d) / ta / 2;
if (sa < sb) printf("2\n%.20lf\n%.20lf\n", (double) sa, (double) sb);
else printf("2\n%.20lf\n%.20lf\n", (double) sb, (double) sa);
}
else if (b * b - 4 * a * c < 0) printf("0\n");
else printf("1\n%.20lf\n", (double) (-tb / (ta * 2)));
}
}