結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-19 00:16:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 559 bytes |
| コンパイル時間 | 637 ms |
| コンパイル使用メモリ | 76,604 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-18 22:15:00 |
| 合計ジャッジ時間 | 3,021 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 122 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
long a,b,c;
main()
{
cin>>a>>b>>c;
cout<<fixed<<setprecision(16);
if(a!=0)
{
long D=b*b-4*a*c;
if(D==0)
{
cout<<1<<endl<<-b/2./a<<endl;
}
else if(D>0)
{
double t=sqrt(D);
double x=(b>0?-b-t:-b+t)/2/a;
double y=c/x/a;
if(x>y)swap(x,y);
cout<<2<<endl<<x<<endl<<y<<endl;
}
else
{
cout<<0<<endl;
}
}
else if(b!=0)
{
cout<<1<<endl<<-c/1./b<<endl;
}
else if(c!=0)
{
cout<<0<<endl;
}
else
{
cout<<-1<<endl;
}
}