結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2020-02-28 02:25:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 935 bytes |
コンパイル時間 | 1,483 ms |
コンパイル使用メモリ | 167,616 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 16:17:12 |
合計ジャッジ時間 | 3,704 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 78 WA * 44 |
ソースコード
#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); 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 << (double)(-c/b) << endl; return 0; } double ans1,ans2; if(b*b == 4*a*c){ cout << 1 << endl; double ans = (double)(-b / (2.0*a)); cout << ans << endl; return 0; } cout << 2 << endl; ans1 = (double)( -b + sqrt(b*b - 4*a*c)); ans2 = (double)( -b - sqrt(b*b - 4*a*c)); ans1 /= (double)2.0*a; ans2 /= (double)2.0*a; cout << ans2 << endl; cout << ans1 << endl; return 0; }