結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-18 00:02:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 729 bytes |
| コンパイル時間 | 1,283 ms |
| コンパイル使用メモリ | 167,428 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 23:30:44 |
| 合計ジャッジ時間 | 3,737 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 118 WA * 4 |
ソースコード
#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%.12f\n",-c*1.0/b);
}
else
{
if(a<0)a=-a,b=-b,c=-c;
double d=b*b-4.0*a*c;
if(fabs(d)<1e-9) printf("1\n%.12f\n",-b/2.0/a);
else if(d<0) puts("0");
else
{
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%.12f\n%.12f\n",x,y);
}
}
return 0;
}