結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
|
提出日時 | 2019-12-18 00:32:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 742 bytes |
コンパイル時間 | 1,206 ms |
コンパイル使用メモリ | 167,160 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 23:57:16 |
合計ジャッジ時間 | 3,381 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 79 WA * 43 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main() { long long a,b,c; scanf("%lld%lld%lld",&a,&b,&c); if(a==0) { if(b==0) puts(c?"0":"-1"); else printf("1\n%.15f\n",-c*1.0/b); } else { if(a<0)a=-a,b=-b,c=-c; long double d=b*b-4.0*a*c; if(abs(d)<1e-12) printf("1\n%.15lf\n",-b/2.0/a); else if(d<0) puts("0"); else { long double x,y; if(b>0) { x=(-b-sqrt(d))/2/a; y=c*1.0/a/x; } else { y=(-b+sqrt(d))/2/a; x=c*1.0/a/y; } printf("2\n%.15lf\n%.15lf\n",x,y); } } return 0; }