結果
問題 | No.1179 Quadratic Equation |
ユーザー | kotatsugame |
提出日時 | 2020-08-21 21:48:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 770 ms |
コンパイル使用メモリ | 80,212 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 05:31:57 |
合計ジャッジ時間 | 1,322 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cmath> using namespace std; int A,B,C; double a,b,c; main() { cin>>A>>B>>C; int D=B*B-4*A*C; vector<double>ans; a=A; b=B; c=C; if(D<0); else if(D==0) { ans.push_back(-b/2/a); } else { double d=sqrt(D),x; if(b>0)x=(-b-d)/2/a; else x=(-b+d)/2/a; ans.push_back(x); ans.push_back(-b/a-x); sort(ans.begin(),ans.end()); } if(ans.empty())cout<<"imaginary"<<endl; else for(int i=0;i<ans.size();i++)cout<<ans[i]<<(i+1==ans.size()?"\n":" "); }