結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2020-05-16 03:57:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,340 bytes |
| コンパイル時間 | 1,205 ms |
| コンパイル使用メモリ | 159,696 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-19 20:15:06 |
| 合計ジャッジ時間 | 4,495 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 60 WA * 62 |
ソースコード
/**
* @FileName f.cpp
* @Author kanpurin
* @Created 2020.05.16 03:57:49
**/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
long double a, b, c;
cin >> a >> b >> c;
if (a != 0) {
if (b * b - 4 * a * c > 0) {
cout << 2 << endl;
long double x, y;
if (b >= 0) {
x = (-b - sqrtl(b * b - 4 * a * c)) / (2 * a);
y = -b / a - x;
} else {
x = (-b + sqrtl(b * b - 4 * a * c)) / (2 * a);
y = -b / a - x;
}
if (x < y) {
cout << fixed << setprecision(20) << x << endl;
cout << fixed << setprecision(20) << y << endl;
} else {
cout << fixed << setprecision(20) << x << endl;
cout << fixed << setprecision(20) << y << endl;
}
} else if (b * b - 4 * a * c == 0) {
cout << 1 << endl;
cout << fixed << setprecision(20) << -b / (2 * a) << endl;
} else {
cout << 0 << endl;
}
} else if (b != 0) {
cout << 1 << endl;
cout << fixed << setprecision(20) << -b / (2 * a) << endl;
} else if (c != 0) {
cout << 0 << endl;
} else {
cout << -1 << endl;
}
return 0;
}
🍮かんプリン