結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2019-12-18 00:44:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,131 bytes |
| コンパイル時間 | 1,642 ms |
| コンパイル使用メモリ | 166,944 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 00:00:00 |
| 合計ジャッジ時間 | 4,475 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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");
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;
}
tko919