結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
shinchan
|
| 提出日時 | 2023-04-16 23:03:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,146 bytes |
| コンパイル時間 | 1,942 ms |
| コンパイル使用メモリ | 195,204 KB |
| 最終ジャッジ日時 | 2025-02-12 09:21:59 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 90 WA * 32 |
ソースコード
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
// ctrl-E
typedef long double ld;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll a, b, c;
cin >> a >> b >> c;
if(a == 0) {
if(b == 0) {
cout << (c ? 0 : -1) << endl;
} else {
cout << 1 << endl;
doublecout(- (ld)c / (ld)b);
}
return 0;
}
ll D = b * b - a * c * 4;
if(D < 0) {
cout << 0 << endl;
} else if(D == 0) {
cout << 1 << endl;
doublecout(- (ld)b / (ld)(a * 2));
} else {
cout << 2 << endl;
ld A = (ld)a;
ld B = (ld)b;
ld C = (ld)c;
ld a2 = A * (ld)2;
ld pm = sqrt(B*B - A*C* (ld)4);
ld base = - (ld)b / a2;
pm /= a2;
doublecout(base - pm);
doublecout(base + pm);
}
return 0;
}
shinchan