結果
| 問題 |
No.1179 Quadratic Equation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-21 21:23:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 2,340 ms |
| コンパイル使用メモリ | 191,788 KB |
| 最終ジャッジ日時 | 2025-01-13 04:57:40 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%lld%lld%lld", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a < 0)a = -a, b = -b, c = -c;
long double d = b * b - 4.0L * a * c;
if (abs(d) < 1e-12) printf("%.15Lf\n", -b / 2.0L / a);
else if (d < 0) puts("imaginary");
else {
long double x, y;
if (b > 0) {
x = (-b - sqrt(d)) / 2 / a;
y = c * 1.0L / a / x;
} else {
y = (-b + sqrt(d)) / 2 / a;
x = c * 1.0L / a / y;
}
printf("%.15Lf %.15Lf\n", x, y);
}
return 0;
}