結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
|
提出日時 | 2022-10-13 05:46:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,025 bytes |
コンパイル時間 | 1,936 ms |
コンパイル使用メモリ | 199,408 KB |
最終ジャッジ日時 | 2025-02-08 02:23:53 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 98 WA * 24 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); using ld = long double; ld a,b,c; cin >> a >> b >> c; if(a == 0) { if(b == 0) { if(c == 0) { cout << -1 << endl; } else { cout << 0 << endl; } } else { cout << 1 << endl; cout << fixed << setprecision(20) << -c/b << endl; } } else { ld D = b * b - 4.0 * a * c; if(D < 0) { cout << 0 << endl; } else if(D == 0) { cout << 1 << endl; cout << fixed << setprecision(20) << -b/(2.0*a) << endl; } else { cout << 2 << endl; set<ld> st; st.insert((-b - sqrtl(D)) / (2.0 * a)); st.insert((-b + sqrtl(D)) / (2.0 * a)); for(ld x : st) cout << fixed << setprecision(20) << x << endl; } } }