結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2020-02-28 02:28:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,071 bytes |
コンパイル時間 | 1,417 ms |
コンパイル使用メモリ | 168,584 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 16:17:32 |
合計ジャッジ時間 | 4,004 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 98 WA * 24 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; bool chmax(int &a,int b){ if(a<b){ a = b; return 1; } return 0; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); long double a,b,c; cin>>a>>b>>c; if(a==0 && b==0){ if(c)cout << 0 << endl; else cout << -1 << endl; return 0; } if(a==0){ cout << 1 << endl; cout << (long double)(-c/b) << endl; return 0; } double ans1,ans2; if(b*b < 4*a*c){ cout << 0 << endl; return 0; } if(b*b == 4*a*c){ cout << 1 << endl; double ans = (long double)(-b / (2.0*a)); cout << ans << endl; return 0; } cout << 2 << endl; ans1 = (long double)( -b + sqrt(b*b - 4*a*c)); ans2 = (long double)( -b - sqrt(b*b - 4*a*c)); ans1 /= (long double)2.0*a; ans2 /= (long double)2.0*a; if(a<0) swap(ans1,ans2); cout << ans2 << endl; cout << ans1 << endl; return 0; }