結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
le_panda_noir
|
| 提出日時 | 2020-02-20 20:41:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,406 bytes |
| コンパイル時間 | 1,537 ms |
| コンパイル使用メモリ | 107,828 KB |
| 最終ジャッジ日時 | 2025-01-09 01:09:54 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 76 WA * 46 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)
#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}
#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif
int main() {
ll a, b, c;
cin >> a >> b >> c;
if (a < 0) {
a *= -1;
b *= -1;
c *= -1;
}
if (a == b && b == c && c == 0) {
cout << 0 << endl;
return 0;
}
if (a == 0) {
if (b == 0 || c < 0) {
cout << 0 << endl;
return 0;
}
cout << 1 << endl;
cout << (double)-c / b << endl;
return 0;
}
ll D = b * b - 4 * a * c;
if (D < 0) {
cout << 0 << endl;
return 0;
}
if (D == 0) {
cout << 1 << endl;
cout << fixed << setprecision(16) << (double)(-b) / (2 * a) << endl;
return 0;
}
cout << 2 << endl;
cout << fixed << setprecision(16) << (double)(-b - sqrt(D)) / (2 * a) << endl;
cout << fixed << setprecision(16) << (double)(-b + sqrt(D)) / (2 * a) << endl;
return 0;
}
le_panda_noir