結果

問題 No.955 ax^2+bx+c=0
ユーザー mag
提出日時 2020-07-07 14:15:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 1,652 ms
コンパイル使用メモリ 168,340 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-01 06:50:14
合計ジャッジ時間 4,931 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 25 WA * 97
権限があれば一括ダウンロードができます

ソースコード

diff #

#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<<-b/c-x<<endl;
    }else{
      cout<<1<<endl;
      cout<<-b/2*a<<endl;
    }
  }
}
0