結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-08 00:55:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 1,704 ms |
| コンパイル使用メモリ | 192,740 KB |
| 最終ジャッジ日時 | 2025-01-08 22:48:05 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
int main(){
cout<<setprecision(20);
long double a,b,c; cin>>a>>b>>c;
if(a==0){
if(b==0){
if(c==0) cout<<-1<<'\n';
else cout<< 0<<'\n';
}
else{
cout<<1<<'\n';
cout<<-c/b<<'\n';
}
}
else{
auto d=b*b-4*a*c;
if(d<0){
cout<<0<<'\n';
}
else if(d==0){
cout<<1<<'\n';
cout<<-b/(2*a)<<'\n';
}
else{
cout<<2<<'\n';
auto x1=(-b-sqrt(d))/(2*a);
auto x2=(-b+sqrt(d))/(2*a);
cout<<min(x1,x2)<<'\n';
cout<<max(x1,x2)<<'\n';
}
}
return 0;
}