結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2020-07-07 14:16:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 675 bytes |
コンパイル時間 | 1,659 ms |
コンパイル使用メモリ | 166,816 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 06:51:47 |
合計ジャッジ時間 | 4,503 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 25 WA * 97 |
ソースコード
#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); 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{ ll 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; } } }