結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
mag
|
| 提出日時 | 2020-07-07 14:18:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 712 bytes |
| コンパイル時間 | 1,779 ms |
| コンパイル使用メモリ | 167,616 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 06:52:07 |
| 合計ジャッジ時間 | 4,139 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 45 WA * 77 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
int main(){
cin.tie(nullptr);ios_base::sync_with_stdio(false);
cout<<fixed<<setprecision(11);
double a,b,c;cin>>a>>b>>c;
if(a==0&&b==0&&c==0){
cout<<-1<<endl;
}else if(a==0&&b==0&&c!=0){
cout<<-1<<endl;
}else if(a==0&&b!=0){
cout<<1<<endl;
cout<<-c/b<<endl;
}else{
double d=b*b-4*a*c;
if(d<0){
cout<<-1<<endl;
}else if(d>0){
double x=(b>0?-b-sqrt(d)/2*a:-b+sqrt(d)/2*a);
cout<<2<<endl;
cout<<x<<endl;
cout<<c/a*x<<endl;
}else{
cout<<1<<endl;
cout<<-b/2*a<<endl;
}
}
}
mag