結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2020-03-17 18:04:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,512 bytes |
コンパイル時間 | 3,388 ms |
コンパイル使用メモリ | 215,060 KB |
最終ジャッジ日時 | 2025-01-09 07:32:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 97 WA * 25 |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define mod 1000000007 using namespace std; typedef long long ll; template<class T> using V=vector<T>; using Graph = vector<vector<int>>; using P=pair<ll,ll>; typedef unsigned long long ull; typedef long double ldouble; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const ll INF=1e18; int main(){ ll a,b,c; cin>>a>>b>>c; bool ok=1; set<double> x; if(a==0){ if(b==0){ if(c==0){ ok=0; } }else{ x.insert((double)-c/b); } }else{ if(b*b-4*a*c>=0){ ll d=b*b-4*a*c; if(d==0){ x.insert((double)-b/(2*a)); }else{ x.insert((double)(-b+sqrt(d))/(2*a)); x.insert((double)(-b-sqrt(d))/(2*a)); } } } if(ok){ cout<<x.size()<<endl; if(x.size()>0){ while(!x.empty()){ double xx=*begin(x); cout<<fixed<<setprecision(15)<<xx<<endl; x.erase(xx); } } }else cout<<-1<<endl; }