結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
|
提出日時 | 2020-06-04 22:55:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,044 bytes |
コンパイル時間 | 1,512 ms |
コンパイル使用メモリ | 168,120 KB |
実行使用メモリ | 13,768 KB |
最終ジャッジ日時 | 2024-11-30 18:21:22 |
合計ジャッジ時間 | 78,373 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 97 OLE * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; void solve(ld a, ld b, ld c) { // 判別式 ld D = b*b - 4.0L*a*c; cout << fixed << setprecision(10); if(a==0 && b == 0 && c==0) { cout << "3\n"; } else if((a==0 && b==0) || D<0) { cout << "0\n"; } else if(a==0) { // x = -c/b | a==0 cout << "1 " << -c/b << '\n'; } else if(D==0) { // x = -b / 2a cout << "1 " << -b/(2.0L*a) << '\n'; } else { ld x1 = (-b + sqrt(D)) / (2.0L * a); ld x2 = (-b - sqrt(D)) / (2.0L * a); cout << "2 " << min(x1, x2) << ' ' << max(x1, x2) << '\n'; } return; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; for(int i=0; i<T; i++) { int a, b, c; cin >> a >> b >> c; solve(a, b, c); } return 0; }