結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2019-12-18 00:45:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,157 bytes |
コンパイル時間 | 1,347 ms |
コンパイル使用メモリ | 168,032 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 00:00:36 |
合計ジャッジ時間 | 3,724 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 74 WA * 48 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff; template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; } template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; } //template end int main(){ ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); if(a==0){ if(b==0){ printf(c?"0\n":"-1\n"); return 0; } else{ printf("1\n"); double x=-c/b; printf("%.15f\n",x); return 0; } } if(b*b-4*a*c==0){ printf("1\n"); double x=-b/2/a; printf("%.15f\n",x); return 0; } if(b*b-4*a*c<0){ printf("0\n"); return 0; } else{ printf("2\n"); double x=-b-sqrt(b*b-4*a*c); x/=2*a; double y=-b+sqrt(b*b-4*a*c); y/=2*a; if(x>y)swap(x,y); printf("%.15f\n%.15f\n",x,y); return 0; } return 0; }