text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d;
cin >> a >> b >> c;
if (!a && b) {
cout << "1\n";
cout << fixed << setprecision(7) << (-c / b);
return 0;
}
if (!a && !b && !c) {
cout << "-1";
return 0;
}
d = b * b - 4 * a * c;
if (d < 0 || (!a && !b && c)) {
cout << "0";
return 0;
}
d = sqrt(d);
if (a < 0) d = d * -1;
if (!d) {
cout << "1\n";
cout << fixed << setprecision(7) << ((-b - d) / (2 * a));
return 0;
} else {
cout << "2\n";
cout << fixed << setprecision(7) << ((-b - d) / (2 * a)) << "\n";
cout << fixed << setprecision(7) << ((-b + d) / (2 * a)) << "\n";
return 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
while (cin >> a >> b >> c) {
if (a == 0 && b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else if (a == 0 && c == 0)
cout << 1 << endl << 0 << endl;
else if (b == 0 && c == 0)
cout << 1 << endl << 0 << endl;
else if (a == 0)
printf("1\n%.6lf\n", -c * 1.0 / b);
else {
double tmp = b * b - 4 * a * c;
if (tmp < 0)
cout << 0 << endl;
else if (tmp == 0) {
cout << 1 << endl;
printf("%.6lf\n", -b * 1.0 / (2 * a));
} else {
cout << 2 << endl;
double ans = sqrt(tmp);
double x = (-b + ans) / (2 * a);
double y = (-b - ans) / (2 * a);
if (x > y)
printf("%.6lf\n%.6lf\n", y, x);
else
printf("%.6lf\n%.6lf\n", x, y);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
while (cin >> a >> b >> c) {
if (a == 0) {
if (b == 0) {
if (c == 0)
puts("-1");
else
puts("0");
} else {
double ans = -(double)c / (double)b;
printf("1\n%.5lf\n", ans);
}
} else {
double det = (double)b * (double)b * 1.0 - 4.0 * (double)a * (double)c;
if (det < 0)
puts("0");
else if (det == 0) {
double ans = -1.0 * b / (double)(2.0 * a);
printf("1\n%.5lf\n", ans);
} else {
double x1, x2;
x1 = -1.0 * b + sqrt(det);
x2 = -1.0 * b - sqrt(det);
x1 = x1 / (2.0 * a);
x2 = x2 / (2.0 * a);
if (x1 > x2) swap(x1, x2);
printf("2\n%.5lf\n%.5lf\n", x1, x2);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double delta(double a, double b, double c) { return b * b - 4 * a * c; }
int main() {
double a, b, c;
cin >> a >> b >> c;
double s1, s2, de = delta(a, b, c);
if (de < 0) {
cout << 0;
return 0;
}
if (!a && !b && !c) {
cout << -1;
return 0;
}
if (!a && b) {
printf("1\n%.6lf", -c / b);
return 0;
}
if (!b && !a) {
cout << 0;
return 0;
}
s1 = (-b + sqrt(de)) / (2 * a);
s2 = (-b - sqrt(de)) / (2 * a);
if (s1 == s2) {
printf("1\n%.6lf", s1);
return 0;
}
cout << 2 << endl;
printf("%.6lf\n%.6lf\n", min(s1, s2), max(s1, s2));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int no = 0;
double a, b, c, res, res1, res2, d, p, q;
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
return 0;
}
if (a == 0 && b != 0) {
res = -(c / b);
printf("1\n%lf", res);
return 0;
}
if (a == 0 && b == 0) no = 1;
d = b * b - 4 * a * c;
if (d < 0) no = 1;
if (!no) {
p = -b + sqrt(d);
q = -b - sqrt(d);
res1 = p / (2 * a);
res2 = q / (2 * a);
if (res1 == res2) {
printf("1\n%lf", res1);
} else {
double x = min(res1, res2);
double y = max(res1, res2);
printf("2\n%lf\n%lf", x, y);
}
return 0;
}
printf("0");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
x = 0;
char c;
while (!isdigit(c = getchar()))
;
do {
x = x * 10 + c - '0';
} while (isdigit(c = getchar()));
}
template <typename T>
inline void write(T x) {
if (x > 9) write(x / 10);
putchar(x % 10 + 48);
}
void Write(string s) {
for (int i = 0; i < s.length(); i++) {
putchar(s[i]);
}
}
void Sangnt(bool nt[], int n) {
int x = sqrt(n);
nt[0] = true, nt[1] = true;
for (int i = 2; i <= x; i++) {
if (nt[i] == false) {
for (int j = i * i; j <= n; j += i) {
nt[j] = true;
}
}
}
}
void Congdon(int a[], int n) {
for (int i = 1; i < n; i++) {
a[i] += a[i - 1];
}
}
unsigned long long POW(int a, int b) {
if (b == 0) return 1;
unsigned long long y = POW(a, b / 2);
if (b % 2 == 0)
return y * y;
else
return y * y * a;
}
long long UCLN(long long x, long long y) {
long long r, a, b;
a = max(x, y), b = min(x, y);
while (b) {
r = a % b;
a = b, b = r;
}
return a;
}
string add(string a, string b) {
string ans;
while (a.length() < b.length()) a = '0' + a;
while (b.length() < a.length()) b = '0' + b;
ans = a;
int n = ans.length();
int digit, Add = 0;
for (int i = n - 1; i >= 0; i--) {
digit = (a[i] - '0' + b[i] - '0' + Add) % 10;
Add = (a[i] - '0' + b[i] - '0' + Add) / 10;
ans[i] = digit + '0';
}
if (Add == 1) ans = '1' + ans;
while (ans[0] == '0' and ans.length() > 1) ans.erase(0, 1);
return ans;
}
string Minu(string a, string b) {
string ans;
while (a.length() < b.length()) a = '0' + a;
while (b.length() < a.length()) b = '0' + b;
ans = a;
int n = ans.length();
int digit, Add = 0;
for (int i = n - 1; i >= 0; i--) {
digit = a[i] - b[i] - Add;
if (digit < 0) {
digit = digit + 10;
Add = 1;
} else
Add = 0;
ans[i] = digit + '0';
}
while (ans[0] == '0' and ans.length() > 1) ans.erase(0, 1);
return ans;
}
double a, b, c, x, y;
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0) {
cout << -1;
} else {
cout << 0;
}
} else {
cout << 1 << endl;
printf("%.10f", -c / b);
}
} else {
double delta = b * b - 4 * a * c;
if (delta == 0) {
x = -b / 2 / a;
cout << 1 << endl;
printf("%.10f", x);
} else if (delta < 0) {
cout << 0;
} else {
cout << 2 << endl;
x = -(b + sqrt(delta)) / 2 / a;
y = -(b - sqrt(delta)) / 2 / a;
if (x > y) {
swap(x, y);
}
printf("%.10f\n", x);
printf("%.10f", y);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cout << setprecision(6) << fixed;
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0) {
cout << -1;
} else {
cout << 0;
}
} else {
cout << 1 << endl;
cout << -c / b;
}
} else if (pow(b, 2) == 4 * a * c) {
cout << 1 << endl;
cout << -b / (2 * a);
} else if (4 * a * c > pow(b, 2)) {
cout << 0;
} else if (pow(b, 2) > 4 * a * c) {
cout << 2 << endl;
double g = (-b - sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
double h = (-b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
cout << min(g, h) << endl;
cout << max(g, h);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int N = 1010;
long double a, b, c;
int main() {
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
cin >> a >> b >> c;
long double d = (b * b - 4 * a * c);
if (d < 0) {
cout << 0;
return 0;
}
if (a == b && b == c && a == 0) {
cout << -1;
return 0;
}
if (a == b && a == 0) {
cout << 0;
return 0;
}
if (a == 0) {
cout << "1\n";
cout << fixed << setprecision(10) << -c / (b) << "\n";
return 0;
}
d = sqrt(d);
long double x = (-b + d) / (2 * a);
long double y = (-b - d) / (2 * a);
if (x > y) swap(x, y);
if (abs(x - y) < 1e-7) {
cout << "1\n";
cout << fixed << setprecision(10) << x << "\n";
} else {
cout << "2\n";
cout << fixed << setprecision(10) << x << "\n";
cout << fixed << setprecision(10) << y << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
T toDec(string s) {
stringstream is(s);
T res;
is >> res;
return res;
}
template <class T>
string toStr(T n) {
string s;
stringstream is;
is << n;
is >> s;
return s;
}
template <class T>
bool isPrime(T x) {
if (x <= 1) return false;
T i;
for (i = 2; i * i <= x; i++)
if (x % i == 0) return false;
return true;
}
template <class T>
double dist(T x1, T y1, T x2, T y2) {
return sqrt(1. * (x2 - x1) * (x2 - x1) + 1. * (y2 - y1) * (y2 - y1));
}
template <class T>
class Prime {
public:
vector<T> z;
Prime() {
z.resize(1e5 + 7);
for (int i = (0); i < (((int)z.size())); i++) z[i] = 1;
z[0] = 0;
z[1] = 0;
T j;
for (int i = (2); i < (((int)z.size())); i++) {
if (z[i]) {
j = i + i;
while (j < ((int)z.size())) {
z[j] = 0;
j += i;
}
}
}
}
};
int main() {
long long a, b, c;
cin >> a >> b >> c;
double x1, x2, d;
if (a != 0) {
if ((b * b) - 4 * a * c == 0)
printf("1\n%.6f", 1. * -b / ((double)2 * a));
else {
if ((b * b) - 4 * a * c < 0)
printf("0\n");
else {
d = sqrt(1. * ((b * b) - 4 * a * c));
x1 = (1. * -b - d) / (1. * 2 * a);
x2 = (1. * -b + d) / (1. * 2 * a);
if (x1 < x2 + 1e-9)
printf("2\n%.6lf\n%.6lf", x1, x2);
else
printf("2\n%.6lf\n%.6lf", x2, x1);
}
}
} else {
if (b == 0 && c == 0)
printf("-1\n");
else {
if (b == 0)
printf("0\n");
else
printf("1\n%.6lf\n", 1. * -c / b);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long A = 1e16, N = 228228, K = 8;
vector<long double> x;
long double d, a, b, c;
long long i, j, n;
int main() {
cin >> a >> b >> c;
if (!a) {
if (!b && !c) {
puts("-1");
return 0;
;
}
if (!b) {
puts("0");
return 0;
;
}
puts("1");
cout << setprecision(K) << -c / b;
return 0;
;
}
d = b * b - 4 * a * c;
if (d == 0) {
puts("1");
cout << setprecision(K) << (-b) / (2 * a) << "\n";
} else if (d > 0) {
d = sqrt(d), x.push_back((-b + d) / (2 * a)),
x.push_back((-b - d) / (2 * a));
sort(x.begin(), x.end());
if (x[0] == x[1])
puts("1"), cout << x[0];
else
puts("2"), cout << setprecision(K) << x[0] << "\n" << x[1];
} else
puts("0");
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
} else if (a == 0 && b == 0 && c != 0) {
printf("0\n");
} else if (a == 0 && b != 0) {
printf("1\n");
double val = (-1 * c) / (b * 1.0);
printf("%0.8f", val);
} else {
long long d = b * b - 4 * a * c;
if (d < 0) {
printf("0\n");
} else {
double x1 = (-1 * b + sqrt(d)) / (2 * a * 1.0);
double x2 = (-1 * b - sqrt(d)) / (2 * a * 1.0);
if (d == 0) {
printf("1\n");
printf("%0.8f\n", min(x1, x2));
} else {
printf("2\n");
printf("%0.8f\n", min(x1, x2));
printf("%0.8f", max(x1, x2));
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
printf("-1\n");
else
printf("0\n");
} else {
printf("1\n");
printf("%.5lf\n", -1.0 * c / b);
}
} else {
long long sum = b * b - 4 * a * c;
if (sum < 0)
printf("0\n");
else if (sum == 0) {
printf("1\n");
printf("%.5lf\n", -1.0 * b / (2 * a));
} else {
printf("2\n");
double ans[2];
ans[0] = -b + sqrt(sum);
ans[0] /= (2 * a);
ans[1] = -b - sqrt(sum);
ans[1] /= (2 * a);
if (ans[0] > ans[1]) swap(ans[0], ans[1]);
printf("%.5lf\n%.5lf\n", ans[0], ans[1]);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int O = 2e9;
const double E = 1e-9;
const double api = 3.1415926536;
int DX[] = {1, -1, -1, 1};
int DY[] = {-1, 1, 1, -1};
int main() {
long double a, b, c;
cin >> a >> b >> c;
if (a == b && b == c && a == 0) {
cout << -1 << endl;
return 0;
}
if (a == b && b == 0 && c != 0) {
cout << 0 << endl;
return 0;
}
if (a == 0) {
cout << 1 << endl
<< fixed << setprecision(10) << ((double)-1 * c / b) << endl;
return 0;
}
long double sq = b * b - 4 * a * c;
if (sq < 0) {
cout << 0 << endl;
return 0;
}
sq = sqrt(sq);
if (sq == 0) {
cout << 1 << endl << fixed << setprecision(10) << -b / (2 * a) << endl;
return 0;
}
double r1 = (-b + sq) / (2 * a);
double r2 = (-b - sq) / (2 * a);
if (r1 == r2)
cout << 1 << endl << fixed << setprecision(10) << r1 << endl;
else
cout << 2 << endl
<< fixed << setprecision(10) << min(r1, r2) << endl
<< max(r1, r2) << endl;
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
double x1, x2;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0) {
cout << "-1";
return 0;
}
if (c != 0) {
cout << "0";
return 0;
}
} else {
cout << "1" << endl;
double wt = (-c) / (double)b;
cout << fixed << setprecision(10) << wt << endl;
return 0;
}
}
double delta = b * b - 4 * a * c;
if (delta < 0) {
cout << "0";
return 0;
}
if (delta == 0) {
x1 = double((-b) / (2 * a));
cout << "1" << endl;
cout << fixed << setprecision(10) << x1 << endl;
return 0;
}
if (delta > 0) {
cout << "2" << endl;
x1 = double((-b - sqrt(delta)) / (2 * a));
x2 = double((-b + sqrt(delta)) / (2 * a));
cout << fixed << setprecision(10) << min(x1, x2) << endl;
cout << fixed << setprecision(10) << max(x1, x2) << endl;
return 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
set<double> s;
int main() {
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
puts("-1");
else
puts("0");
} else {
puts("1");
double ans = -1.0 * c / b;
printf("%0.5f", ans);
}
} else {
if (b == 0) {
double t = -1.0 * c / a;
if (t < 0) {
puts("0");
return 0;
}
s.insert(sqrt(t));
s.insert(-sqrt(t));
cout << s.size() << endl;
for (auto &v : s) printf("%0.5f\n", v);
} else {
double t = 1.0 * b * b / 4 / a / a - 1.0 * c / a;
if (t < 0) {
puts("0");
return 0;
}
t = sqrt(t);
double ans = t - 1.0 * b / 2 / a;
s.insert(ans);
ans = -t - 1.0 * b / 2 / a;
s.insert(ans);
cout << s.size() << endl;
for (auto &v : s) printf("%0.5f\n", v);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V>& x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T& x) {
int f = 0;
cerr << '{';
for (auto& i : x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
template <class A>
void read(vector<A>& v);
template <class A, size_t S>
void read(array<A, S>& a);
template <class T>
void read(T& x) {
cin >> x;
}
void read(double& d) {
string t;
read(t);
d = stod(t);
}
void read(long double& d) {
string t;
read(t);
d = stold(t);
}
template <class H, class... T>
void read(H& h, T&... t) {
read(h);
read(t...);
}
template <class A>
void read(vector<A>& x) {
for (auto& a : x) read(a);
}
template <class A, size_t S>
void read(array<A, S>& x) {
for (auto& a : x) read(a);
}
const int MAXN = 2e5 + 5;
long long mod = 1e9 + 7;
vector<long long> gr[200005];
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long val = (b * b) - (4 * a * c);
cout << setprecision(8);
if (a == 0) {
if ((b == 0)) {
if (c == 0) {
cout << -1 << "\n";
return;
}
cout << 0 << "\n";
} else {
cout << 1 << "\n";
long double ans = -(c * 1.0) / (b * 1.0);
cout << ans << "\n";
}
return;
}
if (val < 0) {
cout << 0 << "\n";
return;
} else {
long double root1 = -b + sqrt(val);
root1 /= 2.0 * a;
long double root2 = -b - sqrt(val);
root2 /= 2.0 * a;
if (root1 == root2) {
cout << 1 << "\n";
cout << root1 << "\n";
} else {
cout << 2 << "\n";
if (root1 < root2) {
cout << root1 << "\n" << root2 << "\n";
} else {
cout << root2 << "\n" << root1 << "\n";
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long test;
test = 1;
while (test--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, e, f, g, h;
double x1, x2, x3, z, m, d;
cin >> a >> b >> c;
m = ((b * b) - (4 * a * c));
if (m < 0) {
cout << 0 << endl;
} else if (a == 0) {
if (b == 0 && c != 0) {
cout << 0 << endl;
} else if (b == 0 && c == 0) {
cout << -1 << endl;
} else {
cout << 1 << endl;
d = (-c) / b;
printf("%5lf", d);
cout << endl;
}
} else {
x1 = ((-b) + sqrt(m)) / (2 * a);
x2 = ((-b) - sqrt(m)) / (2 * a);
if (x1 == x2) {
cout << "1" << endl;
printf("%5lf", x1);
cout << endl;
} else if (x1 > x2) {
cout << "2" << endl;
printf("%5lf", x2);
cout << endl;
printf("%5lf", x1);
cout << endl;
} else {
cout << "2" << endl;
printf("%5lf", x1);
cout << endl;
printf("%5lf", x2);
cout << endl;
}
}
}
|
#include <bits/stdc++.h>
int main() {
long long w, x, y, z;
double a, b;
scanf("%lld %lld %lld", &w, &x, &y);
if (w) {
z = x * x - (4 * w * y);
if (z > 0) {
a = (-x - sqrt(z)) / (2 * w);
b = (-x + sqrt(z)) / (2 * w);
if (w > 0)
printf("2\n%lf\n%lf\n", a, b);
else
printf("2\n%lf\n%lf\n", b, a);
} else if (z == 0) {
printf("1\n%lf\n", -1. * x / 2 / w);
} else
printf("0\n");
} else if (x)
printf("1\n%lf\n", -1. * y / x);
else if (y)
printf("0\n");
else
printf("-1\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0)
printf(c == 0 ? "-1\n" : "0\n");
else
printf("1\n%f\n", (double)-c / b);
return 0;
}
long long d = (long long)b * b - 4LL * a * c;
if (d < 0)
printf("0\n");
else if (d == 0)
printf("1\n%f\n", -b / 2.0 / a);
else {
double r = sqrt(d);
double x1 = (-b - r) / 2 / a;
double x2 = (-b + r) / 2 / a;
if (x1 > x2) swap(x1, x2);
printf("2\n%f\n%f\n", x1, x2);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c, x1, x2;
int main() {
int i, j, k, m, n, ans, len;
while (scanf("%lf%lf%lf", &a, &b, &c) != EOF) {
if (fabs(a) < 1e-8) {
if (fabs(b) < 1e-8) {
if (fabs(c) < 1e-8)
printf("-1\n");
else
printf("0\n");
} else {
if (fabs(c) < 1e-8)
printf("1\n0.000000000000\n");
else
printf("1\n%.10f\n", -c / b);
}
} else {
double det = b * b - 4 * a * c;
if (fabs(det) < 1e-8) {
double x = (-b + sqrt(det)) / 2 / a;
if (fabs(x) < 1e-8)
printf("1\n%.10f\n", fabs(x));
else
printf("1\n%.10f\n", x);
} else if (det < 0)
printf("0\n");
else {
x1 = (-b + sqrt(det)) / 2 / a;
x2 = (-b - sqrt(det)) / 2 / a;
if (fabs(x1) < 1e-8) x1 = 0;
if (fabs(x2) < 1e-8) x2 = 0;
if (fabs(x1 - x2) < 1e-8) {
printf("1\n%.10f\n", x1);
} else {
printf("2\n");
if (x1 < x2)
printf("%.10f\n%.10f\n", x1, x2);
else
printf("%.10f\n%.10f\n", x2, x1);
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, b, c, x1;
cin >> a >> b >> c;
double y, y1, y2;
if (a == 0 && b == 0 && c == 0)
cout << "-1";
else if (a == 0) {
if (b != 0) {
cout << "1"
<< "\n";
double y = ((double)(-c)) / b;
cout << fixed << showpoint;
cout << setprecision(10);
cout << y << "\n";
}
if (b == 0)
cout << "0"
<< "\n";
} else {
x1 = b * b - 4 * a * c;
if (x1 < 0) {
cout << "0"
<< "\n";
}
if (x1 == 0) {
cout << "1"
<< "\n";
y = ((double)-b) / (2 * a);
cout << fixed << showpoint;
cout << setprecision(10);
cout << y << "\n";
}
if (x1 > 0) {
cout << "2"
<< "\n";
y1 = (double)(-b + sqrt(x1)) / (2 * a);
cout << fixed << showpoint;
cout << setprecision(10);
y2 = (double)(-b - sqrt(x1)) / (2 * a);
if (a > 0) {
cout << fixed << showpoint;
cout << setprecision(10);
cout << y2 << "\n";
cout << fixed << showpoint;
cout << setprecision(10);
cout << y1 << "\n";
}
if (a < 0) {
cout << fixed << showpoint;
cout << setprecision(10);
cout << y1 << "\n";
cout << fixed << showpoint;
cout << setprecision(10);
cout << y2 << "\n";
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int Z = (int)1e5 + 111;
const int inf = (int)1e9 + 111;
const long long llinf = (long long)1e18 + 5;
int main() {
ios_base::sync_with_stdio(false);
long double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << -1;
return 0;
}
if (a == 0 && b == 0 && c != 0) {
cout << 0;
return 0;
}
if (a == 0) {
cout << "1\n";
long double h = -c / b;
cout.precision(15);
cout << h;
return 0;
}
long double d = b * b - 4 * a * c;
if (d < 0) {
cout << 0;
return 0;
}
if (d == 0) {
cout << "1\n";
d = -b / (2 * a);
cout.precision(15);
cout << d;
} else {
cout << "2\n";
vector<long double> ans;
ans.push_back((-b - sqrt(d)) / (2 * a));
cout.precision(15);
ans.push_back((-b + sqrt(d)) / (2 * a));
sort((ans).begin(), (ans).end());
cout << ans[0] << '\n';
cout << ans[1];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double sqrtt(double x) {
if (x < 0)
return -sqrt(-x);
else
return sqrt(x);
}
int main() {
double a, b, c;
double x1, x2;
while (cin >> a >> b >> c) {
if (a == 0 && b == 0) {
if (c == 0)
printf("-1\n");
else
printf("0\n");
} else if (a == 0 && c == 0) {
printf("1\n0\n");
} else if (b == 0 && c == 0) {
printf("1\n0\n");
} else if (a == 0) {
printf("1\n");
printf("%.6lf\n", -c / b);
} else {
double tem = b * b - 4 * a * c;
if (tem < 0)
printf("0\n");
else if (tem == 0) {
printf("1\n");
printf("%.6lf\n", (-b / (2 * a)));
} else {
printf("2\n");
x1 = (-b - sqrtt(tem)) / (2 * a);
x2 = (-b + sqrtt(tem)) / (2 * a);
if (x1 > x2) swap(x1, x2);
printf("%.6lf\n%.6f\n", x1, x2);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
int main() {
istream &fin = cin;
ostream &fout = cout;
FILE *fpin = stdin;
FILE *fpout = stdout;
int A, B, C;
fin >> A >> B >> C;
if (A == 0 && B == 0 && C == 0) {
fout << -1 << endl;
return 0;
}
if (A == 0) {
if (B == 0) {
fout << 0 << endl;
return 0;
}
fout << 1 << endl;
fout << fixed << setprecision(15) << (double)(-C) / B << endl;
return 0;
}
long long D = (long long)B * B - 4LL * A * C;
if (D < 0) {
fout << 0 << endl;
return 0;
}
if (D == 0) {
fout << 1 << endl;
fout << fixed << setprecision(15) << (double)(-B) / (2. * A) << endl;
return 0;
}
fout << 2 << endl;
double res1 = ((double)(-B) + sqrt((double)D)) / (2. * A);
double res2 = ((double)(-B) - sqrt((double)D)) / (2. * A);
if (res1 > res2) swap(res1, res2);
fout << fixed << setprecision(15) << res1 << endl;
fout << fixed << setprecision(15) << res2 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
double A, B, C, d;
void Stampa(double x) { cout << fixed << setprecision(7) << x << endl; }
double Delta() { return pow(B, 2) - 4 * A * C; }
int main() {
ios::sync_with_stdio(false);
cin >> A >> B >> C;
if (A == 0) {
if (B == 0 && C == 0) {
cout << "-1\n";
return 0;
} else if (B == 0 && C != 0) {
cout << "0\n";
return 0;
} else if (B != 0 && C == 0) {
cout << "1\n";
Stampa(0);
return 0;
} else {
cout << "1\n";
Stampa(-C / B);
return 0;
}
} else if (B == 0) {
if (C == 0) {
cout << "1\n";
Stampa(0);
return 0;
} else {
if ((-C / A) < 0) {
cout << "0\n";
return 0;
}
double x1 = sqrt((-C / A));
double x2 = -x1;
cout << "2\n";
Stampa(x2);
Stampa(x1);
return 0;
}
} else if (C == 0) {
double x = (-B / A);
cout << "2\n";
if (x > 0) {
Stampa(0);
Stampa(x);
} else {
Stampa(x);
Stampa(0);
}
return 0;
} else {
d = Delta();
if (d < 0) {
cout << "0\n";
return 0;
} else if (d == 0) {
cout << "1\n";
Stampa(-B / (2 * A));
return 0;
} else {
double x1 = ((-B - sqrt(d)) / (2 * A));
double x2 = ((-B + sqrt(d)) / (2 * A));
cout << "2\n";
Stampa(min(x1, x2));
Stampa(max(x1, x2));
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long A, B, C;
cin >> A >> B >> C;
if (A == 0) {
if (B == 0) {
cout << (C == 0 ? -1 : 0) << '\n';
} else {
cout << 1 << '\n';
cout << fixed << setprecision(10) << -1. * C / B << '\n';
}
} else {
long long det = B * B - 4 * A * C;
if (det > 0) {
cout << 2 << '\n';
cout << fixed << setprecision(10);
double a[2] = {(-B - sqrt(det)) / 2 / A, (-B + sqrt(det)) / 2 / A};
sort(a, a + 2);
cout << a[0] << '\n' << a[1] << '\n';
} else if (det == 0) {
cout << 1 << '\n';
cout << fixed << setprecision(10);
cout << -B / 2. / A << '\n';
} else
cout << 0 << '\n';
}
}
|
#include <bits/stdc++.h>
int main() {
double a, b, c;
int i, j, k, m, n;
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0) {
if (b == 0) {
if (c == 0)
printf("-1\n");
else
printf("0\n");
} else
printf("1\n%0.10f\n", -c / b);
} else {
if (b * b - 4 * a * c < 0)
printf("0\n");
else if (b * b - 4 * a * c == 0)
printf("1\n%0.10f\n", -b / (2 * a));
else {
printf("2\n");
if ((-b - sqrt(b * b - 4 * a * c)) / (2 * a) <
(-b + sqrt(b * b - 4 * a * c)) / (2 * a)) {
printf("%.10lf\n", (-b - sqrt(b * b - 4 * a * c)) / (2 * a));
printf("%.10lf\n", (-b + sqrt(b * b - 4 * a * c)) / (2 * a));
} else {
printf("%.10lf\n", (-b + sqrt(b * b - 4 * a * c)) / (2 * a));
printf("%.10lf\n", (-b - sqrt(b * b - 4 * a * c)) / (2 * a));
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int main() {
scanf("%lld%lld%lld", &a, &b, &c);
if (a == 0 && b == 0 && c == 0)
printf("-1\n");
else if (a == 0 && b == 0 && c != 0)
printf("0\n");
else if (a == 0 && b != 0)
printf("1\n%.10lf\n", -(double)(c) / b);
else {
int num = b * b - 4 * a * c;
if (num < 0)
printf("0\n");
else if (num == 0) {
printf("1\n");
double ans = double(-b) / (2 * a);
printf("%.10lf\n", ans);
} else {
printf("2\n");
double s = sqrt(b * b - 4 * a * c);
double x1 = double(-b + s) / (a * 2);
double x2 = double(-b - s) / (a * 2);
if (x1 > x2) swap(x1, x2);
printf("%.10lf\n%.10lf\n", x1, x2);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double i, a, b, c;
double ans, d, r1, r2;
cin >> a >> b >> c;
d = (b * b - 4 * a * c);
if (a == 0 && (b == 0 && c == 0)) {
cout << "-1";
} else if (a == 0 && b != 0) {
r1 = -c / b;
printf("1\n%.6f", r1);
} else if (a == 0 && b == 0) {
cout << "0";
} else {
if (d == 0) {
ans = 1;
r1 = -b / (2 * a);
printf("1\n%.6f", r1);
} else if (d < 0) {
ans = 0;
cout << ans;
} else {
ans = 2;
r1 = (-b + sqrt(d)) / (2 * a);
r2 = (-b - sqrt(d)) / (2 * a);
if (r2 >= r1)
printf("2\n%6f\n%6f", r1, r2);
else
printf("2\n%6f\n%6f", r2, r1);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, dt;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0 && c == 0)
cout << -1;
else if (b == 0 && c != 0)
cout << 0;
else if (b != 0 && c != 0) {
cout << 1 << "\n";
printf("%.8lf", -c / b);
} else {
cout << 1 << "\n" << 0.00000000;
}
} else {
dt = b * b - 4 * a * c;
if (dt < 0) {
cout << 0;
} else if (dt == 0) {
cout << 1 << "\n";
printf("%.8lf", -b / (2 * a));
} else {
cout << 2 << "\n";
double x = (-b - sqrt(dt)) / (2 * a);
double y = (-b + sqrt(dt)) / (2 * a);
if (x < y)
printf("%.8lf\n%.8lf", x, y);
else
printf("%.8lf\n%.8lf", y, x);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, s, d;
cin >> a >> s >> d;
long long ans = s * s - 4 * a * d;
if (!a) {
double aa = -d;
aa /= s;
if (!s && d)
cout << 0;
else if (isinf(aa) || (!s && !d))
cout << -1;
else
cout << 1 << endl << setprecision(9) << aa;
} else if (ans < 0)
cout << 0;
else if (isinf(sqrt(ans)))
cout << -1;
else {
double sq = sqrt(ans);
double aa = (-s - sq) / (2 * a), aa2 = (-s + sq) / (2 * a);
if (aa == aa2)
cout << 1 << endl << setprecision(15) << aa;
else
cout << 2 << endl
<< setprecision(15) << min(aa, aa2) << endl
<< setprecision(15) << max(aa, aa2);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MODN = 1000000007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
double a, b, c;
cin >> a >> b >> c;
cout << fixed << setprecision(5);
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else {
cout << 1 << endl;
cout << -c / b << endl;
}
} else {
double d = b * b - 4 * a * c;
if (d < 0) {
cout << 0 << endl;
} else if (d < 1e-7) {
cout << 1 << endl;
cout << -b / (2 * a) << endl;
} else {
cout << 2 << endl;
double r1 = (-b - sqrt(d)) / (2 * a);
double r2 = (-b + sqrt(d)) / (2 * a);
if (r1 > r2) swap(r1, r2);
cout << r1 << endl << r2 << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, d;
cout.precision(10);
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1;
else
cout << 0;
} else {
long double cc = -c + 0.0;
cout << 1 << endl << cc / b;
}
} else {
d = b * b - 4 * a * c;
if (d < 0) {
cout << 0;
} else if (d > 0) {
long double sq = sqrt(d);
cout << 2 << endl;
if (a > 0) {
cout << (-b - sq) / (2 * a) << endl;
cout << (-b + sq) / (2 * a);
} else {
cout << (-b + sq) / (2 * a) << endl;
cout << (-b - sq) / (2 * a);
}
} else {
cout << 1 << endl << -b / (2 * a);
}
}
return 0;
}
|
#include <bits/stdc++.h>
const double eps = 1e-8;
const double pi = 3.1415926535897932;
using namespace std;
ifstream in("input.txt", ifstream::in);
ofstream out("output.txt", ofstream::out);
int main() {
double ans[2];
long long A, B, C;
cin >> A >> B >> C;
if (A == 0) {
if (B == 0) {
if (C == 0)
cout << -1;
else
cout << 0;
} else {
if (C == 0)
cout << "1\n0.000000";
else {
cout << 1 << endl;
cout << fixed << setprecision(6) << (double)-C / B;
}
}
} else if (B == 0) {
if (C == 0)
cout << "1\n0.000000";
else {
if (C < 0) {
cout << 2 << endl;
ans[0] = sqrt((double)C / A);
ans[1] = -ans[0];
if (ans[0] > ans[1]) swap(ans[0], ans[1]);
cout << fixed << setprecision(6) << ans[0] << endl << ans[1];
} else
cout << 0;
}
} else {
double D = B * B - 4 * A * C;
if (D > 0) {
D = sqrt(D);
cout << 2 << endl;
ans[0] = (-B + D) / (2 * A);
ans[1] = (-B - D) / (2 * A);
if (ans[0] > ans[1]) swap(ans[0], ans[1]);
cout << fixed << setprecision(6) << ans[0] << endl << ans[1];
} else if (D == 0) {
cout << 1 << endl;
cout << fixed << setprecision(6) << (double)-B / 2 / A;
} else
cout << 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void PTBac1(long long a, long long b) {
if (a == 0) {
if (b == 0) {
cout << "-1";
} else {
cout << "0";
}
} else {
cout << "1\n";
cout << fixed << setprecision(5) << 1.0 * -b / a;
}
}
void PTBac2(long long a, long long b, long long c) {
long long delta = b * b - 4 * a * c;
if (delta < 0) {
cout << "0";
} else if (delta == 0) {
cout << "1\n";
cout << fixed << setprecision(5) << -1.0 * b / 2 / a;
} else {
cout << "2\n";
double x1 = (-b + sqrt(delta)) / 2 / a;
double x2 = (-b - sqrt(delta)) / 2 / a;
if (x1 < x2) {
cout << fixed << setprecision(5) << x1 << endl;
cout << fixed << setprecision(5) << x2;
} else {
cout << fixed << setprecision(5) << x2 << endl;
cout << fixed << setprecision(5) << x1;
}
}
}
int main() {
long long a, b, c;
cin >> a >> b >> c;
if (a == 0) {
PTBac1(b, c);
} else {
PTBac2(a, b, c);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
long double a, b, c;
cin >> a >> b >> c;
if (a == 0 and b == 0 and c == 0)
cout << -1;
else if ((a == 0 and b == 0) or b * b - 4 * a * c < 0)
cout << 0;
else if (a == 0)
cout << fixed << setprecision(10) << "1\n" << (-1) * (c / b);
else {
long double q = ((-1) * b + sqrt(b * b - 4 * a * c)) / (2 * a);
long double p = ((-1) * b - sqrt(b * b - 4 * a * c)) / (2 * a);
if (q == p)
cout << fixed << setprecision(10) << "1\n" << q;
else
cout << fixed << setprecision(10) << "2\n"
<< min(q, p) << "\n"
<< max(q, p);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
typename std::set<T>::const_iterator GetNearestTo(const std::set<T>& data,
const T& t) {
auto upper = data.lower_bound(t);
if (upper == data.begin() || (*upper) == t) return upper;
auto lower = upper;
--lower;
if (data.end() == lower || (t - (*lower)) < ((*upper) - t)) return lower;
if (upper == data.end() && data.size() > 0) return (--upper);
return upper;
}
int main() {
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0) {
cout << "-1" << endl;
return 0;
} else {
cout << "0" << endl;
return 0;
}
} else {
cout << "1" << endl;
double x = (-c) / b;
printf("%0.6f\n", x);
return 0;
}
} else {
double d = b * b - 4 * a * c;
if (d < 0) {
cout << "0" << endl;
return 0;
}
d = sqrt(d);
double p = (-b + d);
double q = (-b - d);
p = p / 2 / a;
q = q / 2 / a;
if (p == q) {
cout << "1" << endl;
printf("%0.6f\n", p);
return 0;
} else {
cout << "2" << endl;
if (p > q) {
printf("%0.6f\n", q);
printf("%0.6f\n", p);
return 0;
} else {
printf("%0.6f\n", p);
printf("%0.6f\n", q);
return 0;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
double a, b, c, s;
scanf("%lf %lf %lf", &a, &b, &c);
if (a == 0 && b == 0 && c == 0) {
printf("-1");
} else if (a == 0 && b != 0) {
printf("1\n%lf", (-c) / b);
} else if (a == 0 && b == 0 && c != 0) {
printf("%lf", b);
} else {
s = (b * b) - 4 * a * c;
if (s > 0) {
double w, e;
w = (((-b) - sqrt(s)) / (2 * a));
e = (((-b) + sqrt(s)) / (2 * a));
if (w > e)
printf("2\n%lf \n%lf", e, w);
else
printf("2\n%lf \n%lf", w, e);
}
if (s == 0) {
printf("1\n%lf", ((-b) / (2 * a)));
}
if (s < 0) {
printf("0");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double A, B, C;
cin >> A >> B >> C;
if (A == 0 && B == 0 && C == 0) {
cout << "-1";
return 0;
}
if (A == 0 && B == 0 && C != 0) {
cout << "0";
return 0;
}
if (A == 0) {
double z = (-C) / B;
printf("1\n%.10lf", z);
return 0;
} else {
double der = (B * B - 4 * A * C);
if (der < 0) {
cout << 0;
return 0;
}
if (der == 0) {
printf("1\n%.10lf", (-B) / (2 * A));
}
if (der > 0) {
double x1 = (-B + sqrt(der)) / (2 * A), x2 = (-B - sqrt(der)) / (2 * A);
double q = min(x1, x2), p = max(x1, x2);
printf("2\n%.10lf\n%.10lf", q, p);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
double a, b, c;
int main() {
cin >> a >> b >> c;
double s = b * b - 4 * a * c;
if (a == b && b == c && a == 0) return puts("-1"), 0;
if (a == 0 && b == 0) return puts("0"), 0;
if (a == 0) {
cout << 1 << endl;
printf("%.6lf\n", (-c) / b);
return 0;
}
if (s < 0) return puts("0"), 0;
if (s == 0) {
cout << 1 << endl;
printf("%.6lf\n", (-b) / (2 * a));
} else {
cout << 2 << endl;
double x = (-b + sqrt(s)) / (2 * a);
double y = (-b - sqrt(s)) / (2 * a);
if (x < y) {
printf("%.6lf\n", x);
printf("%.6lf\n", y);
} else {
printf("%.6lf\n", y);
printf("%.6lf\n", x);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int tc;
double a, b, c;
cin >> a >> b >> c;
double D = b * b - 4 * a * c;
int n;
if (D < 0) {
printf("0\n");
} else if (a == 0 && b == 0 && c == 0)
cout << "-1" << endl;
else if (a == 0 && b == 0)
cout << "0" << endl;
else if (a == 0 && b != 0) {
{
cout << "1\n";
printf("%lf\n", -c / b);
n = -1;
}
} else {
if (D == 0) {
cout << "1\n";
n = 1;
} else {
cout << "2\n";
n = 2;
}
double x1, x2;
x1 = (-b + sqrt(D)) / (2 * a);
x2 = (-b - sqrt(D)) / (2 * a);
if (n == 2) {
if (x1 < x2)
printf("%lf\n%lf\n", x1, x2);
else
printf("%lf\n%lf\n", x2, x1);
} else {
printf("%lf\n", x1);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e6 + 10;
int main() {
double a, b, c;
while (~scanf("%lf%lf%lf", &a, &b, &c)) {
if (a == b && b == c && c == 0) {
printf("-1\n");
continue;
}
double x = b * b - a * 4 * c;
if (((a == 0 && b == 0) && c != 0) || x < 0) {
printf("0\n");
continue;
}
if (x == 0) {
double xx = -b / (2.0 * a);
printf("1\n%.5f\n", xx);
continue;
}
if (a == 0) {
double xx = -c / b;
printf("1\n%.5f\n", xx);
continue;
}
double x1 = (-b + sqrt(x)) / (2.0 * a);
double x2 = (-b - sqrt(x)) / (2.0 * a);
if (x1 > x2) swap(x1, x2);
if (x1 == x2)
printf("1\n%.5f\n", x1);
else
printf("2\n%.5f\n%.5f\n", x1, x2);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
double x, y, d, p;
cin >> a >> b >> c;
d = b * b;
p = 4 * a * c;
d = d - p;
if (a == 0 && b == 0 && c == 0)
cout << "-1" << endl;
else if (a == 0 && b == 0)
cout << "0" << endl;
else if (a == 0) {
x = c * -1;
x = x / b;
printf("1\n%.5lf\n", x);
} else if (d > 0) {
p = sqrt(d);
b = b * -1;
x = (b + p);
x = x / 2.0;
x = x / a;
y = (b - p);
y = y / 2.0;
y = y / a;
if (x > y)
printf("2\n%.7lf\n%.7lf\n", y, x);
else
printf("2\n%.7lf\n%.7lf\n", x, y);
} else if (d < 0)
cout << "0" << endl;
else if (d == 0) {
b = b * -1;
x = b / 2.0;
x = x / a;
printf("1\n%.7lf\n", x);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<double> v;
long long n, m, i, j, t, a, b, c, k;
int main() {
ios_base::sync_with_stdio(0);
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
return 0;
} else if (a == 0 && b == 0) {
cout << 0 << endl;
return 0;
} else if (b * b - 4 * a * c < 0) {
cout << 0 << endl;
return 0;
} else if (b * b - 4 * a * c == 0) {
v.push_back(-(b * 1.0) / (2 * a));
} else if (a == 0 && c == 0) {
v.push_back(0.0);
} else if (c == 0) {
v.push_back(0.0);
v.push_back(-b * 1.0 / a);
} else if (a == 0) {
v.push_back(-c * 1.0 / b);
} else if (b == 0) {
v.push_back(sqrt(-c * 1.0 / a));
v.push_back(-sqrt(-c * 1.0 / a));
} else {
v.push_back((-b + sqrt(b * b - 4 * a * c)) / (2 * a));
v.push_back((-b - sqrt(b * b - 4 * a * c)) / (2 * a));
}
cout << v.size() << endl;
sort(v.begin(), v.end());
for (i = 0; i < v.size(); i++) printf("%0.6f\n", v[i]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
while (~scanf("%lf%lf%lf", &a, &b, &c)) {
if (a == b && b == c && c == 0) {
printf("-1\n");
continue;
}
double x = b * b - a * 4 * c;
if (((a == 0 && b == 0) && c != 0) || x < 0) {
printf("0\n");
continue;
}
if (x == 0) {
double xx = -b / (2.0 * a);
printf("1\n%.5f\n", xx);
continue;
}
if (a == 0) {
double xx = -c / b;
printf("1\n%.5f\n", xx);
continue;
}
double x1 = (-b + sqrt(x)) / (2.0 * a);
double x2 = (-b - sqrt(x)) / (2.0 * a);
if (x1 > x2) swap(x1, x2);
if (x1 == x2)
printf("1\n%.5f\n", x1);
else
printf("2\n%.5f\n%.5f\n", x1, x2);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
double d = pow(b, 2.0) - 4.0 * a * c;
if (d < 0 || a == 0 && b == 0 && c != 0) {
cout << 0 << "\n";
return 0;
} else if (a == 0 && b == 0 && c == 0) {
cout << -1 << "\n";
return 0;
} else if (a == 0) {
cout << 1 << "\n";
cout << fixed << -c / b;
} else if (d == 0) {
cout << 1 << "\n";
cout << fixed << (-b + (sqrt(d))) / (2.0 * a);
} else if (d > 0) {
cout << 2 << '\n';
cout << fixed
<< min(double((-b - double(sqrt(d))) / (2.0 * a)),
double((-b + double(sqrt(d))) / (2.0 * a)))
<< "\n";
cout << fixed
<< max(double((-b - double(sqrt(d))) / (2.0 * a)),
double((-b + double(sqrt(d))) / (2.0 * a)))
<< "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0 and c == 0) {
cout << -1 << endl;
return 0;
} else if (b == 0 and c != 0) {
cout << 0 << endl;
return 0;
}
cout << 1 << endl << fixed << setprecision(5) << (double)(-c) / b << endl;
return 0;
}
long long delta = b * b - 4 * a * c;
if (delta == 0) {
cout << 1 << endl << fixed << setprecision(5) << -b / (2.0 * a);
return 0;
}
if (delta < 0) {
cout << 0 << endl;
return 0;
}
double m = (-b - sqrt(delta)) / (2.0 * a),
mm = (-b + sqrt(delta)) / (2.0 * a);
cout << 2 << endl
<< fixed << setprecision(5) << min(m, mm) << endl
<< max(m, mm) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(10);
double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0)
cout << "-1";
else if (a == 0 && b == 0)
cout << "0";
else if (a == 0) {
cout << "1"
<< "\n";
cout << -1 * (c / b);
return 0;
} else if (b * b < 4 * a * c)
cout << "0";
else {
double x, y, z;
x = (b * b) - (4 * a * c);
x = sqrt(x);
y = -1 * b;
double zz;
z = (y - x) / (2 * a);
zz = (y + x) / (2 * a);
if (z == zz) {
cout << "1"
<< "\n";
cout << z;
return 0;
}
cout << "2"
<< "\n";
cout << min(z, zz) << "\n";
cout << max(z, zz) << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
double d = b * b - 4 * a * c;
if (a == 0 && b == 0 && c == 0) {
cout << "-1\n";
return 0;
}
if (a == 0 && b == 0) {
cout << "0\n";
return 0;
}
if (a == 0) {
cout << "1\n";
printf("%.5lf\n", -c / b);
return 0;
}
if (d < 0) {
cout << "0\n";
return 0;
}
if (d == 0) {
cout << "1\n";
printf("%.5lf\n", -b / (2 * a));
return 0;
}
cout << "2\n";
printf("%.5lf\n", min((-b + sqrt(d)) / (2 * a), (-b - sqrt(d)) / (2 * a)));
printf("%.5lf\n", max((-b + sqrt(d)) / (2 * a), (-b - sqrt(d)) / (2 * a)));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
double a, b, c;
cin >> a >> b >> c;
double d = b * b - 4 * a * c;
if (a == b && b == c && c == 0) {
cout << -1;
return 0;
}
if (a == b && b == 0) {
cout << 0;
return 0;
}
cout << fixed << setprecision(20);
if (a == 0) {
cout << "1\n" << -c / b;
return 0;
}
if (d < 0) {
cout << "0";
return 0;
}
if (d == 0) {
cout << "1\n" << -b / (2 * a);
return 0;
}
cout << "2\n";
cout << min(((-b - sqrt(d)) / (2 * a)), ((-b + sqrt(d)) / (2 * a))) << "\n";
cout << max(((-b - sqrt(d)) / (2 * a)), ((-b + sqrt(d)) / (2 * a))) << "\n";
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
scanf("%lf %lf %lf", &a, &b, &c);
if (a == 0) {
if (b == 0) {
if (c == 0)
printf("-1\n");
else
printf("0\n");
} else {
printf("1\n");
printf("%.6lf\n", -c / b);
}
} else {
double tt = b * b - 4 * a * c, aa, bb;
if (tt < 0)
printf("0\n");
else if (tt == 0)
printf("1\n%.6lf\n", -b / 2 / a);
else {
aa = (-b - sqrt(tt)) / 2 / a, bb = (-b + sqrt(tt)) / 2 / a;
if (aa > bb) swap(aa, bb);
printf("2\n%.6lf\n%.6lf\n", aa, bb);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double A, B, C;
void Output(int n, double x = 0, double y = 0) {
printf("%d\n", n);
if (n >= 2 && x > y) swap(x, y);
if (n >= 1) printf("%.6f\n", x);
if (n >= 2) printf("%.6f\n", y);
}
int main(void) {
scanf("%lf%lf%lf", &A, &B, &C);
if (fabs(A) == 0) {
if (fabs(B) == 0) {
if (fabs(C) == 0)
Output(-1);
else
Output(0);
} else
Output(1, -C / B);
} else {
double D = B * B - 4 * A * C;
if (D < -1e-6)
Output(0);
else if (D < 1e-6)
Output(1, -B / 2 / A);
else
Output(2, (-B - sqrt(D)) / 2 / A, (-B + sqrt(D)) / 2 / A);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long det = b * b - 4 * a * c;
if (a == 0 && b == 0 && c == 0) {
cout << -1;
return 0;
}
if (a == 0 && b == 0 && c != 0) {
cout << 0;
return 0;
}
if (a == 0 && b != 0) {
cout << 1 << '\n';
double r = -(c / double(b));
cout << fixed << setprecision(15) << r;
return 0;
}
if (det < 0) {
cout << 0;
return 0;
} else if (det == 0) {
cout << fixed;
double x = (-b) / double(2 * a);
cout << 1 << '\n';
cout << setprecision(15) << x;
return 0;
} else {
double root1 = (-b + sqrt(det)) / double(2 * a);
double root2 = (-b - sqrt(det)) / double(2 * a);
cout << 2 << '\n';
cout << fixed;
if (root1 > root2) {
cout << setprecision(15) << root2 << '\n' << root1;
return 0;
} else {
cout << setprecision(15) << root1 << '\n' << root2;
return 0;
}
return 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
double r1, r2, a, b, c, delta;
int main() {
cin >> a >> b >> c;
cout << fixed << setprecision(5);
if (a == b && b == c && c == 0) {
cout << -1;
return 0;
}
if (a != 0) {
delta = b * b - 4 * a * c;
if (delta == 0) {
cout << 1 << endl << ((-1) * b) / (2 * a);
return 0;
}
if (delta > 0) {
r1 = (-1 * b + sqrt(delta)) / (2 * a);
r2 = (-1 * b - sqrt(delta)) / (2 * a);
cout << 2 << endl << min(r1, r2) << endl << max(r1, r2);
return 0;
}
if (delta < 0) {
cout << 0;
return 0;
}
}
if (a == 0 && b != 0) {
cout << 1 << endl << c / b * -1;
return 0;
}
if (a == 0 && b == 0) {
cout << 0;
return 0;
}
cout << -1;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long d = b * b - 4 * a * c;
if (a != 0) {
double x = a, y = b;
if (d < 0) cout << 0;
if (d == 0) {
cout << 1 << endl;
printf("%lf", -y / (2 * x));
}
if (d > 0) {
cout << 2 << endl;
if (x > 0)
printf("%lf\n%lf", (-y - sqrt(d)) / (2 * x), (-y + sqrt(d)) / (2 * x));
else
printf("%lf\n%lf", (-y + sqrt(d)) / (2 * x), (-y - sqrt(d)) / (2 * x));
}
} else {
if (b == 0) {
if (c == 0)
cout << -1;
else
cout << 0;
} else {
double s = c, t = b;
cout << 1 << endl;
printf("%lf", -s / t);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c, d;
int main() {
cin >> a >> b >> c;
if (a == b && a == c && a == 0) {
cout << -1;
return 0;
}
if (a == 0 && b == 0) {
cout << 0;
return 0;
}
if (a == 0) {
cout << 1 << endl;
cout << fixed;
cout << setprecision(9) << -c / b;
return 0;
}
d = b * b - 4 * a * c;
if (d < 0) {
cout << 0;
return 0;
}
if (d == 0) {
cout << 1 << endl;
cout << fixed;
cout << setprecision(6) << (-b - sqrt(d)) / ((double)2 * a);
return 0;
}
cout << 2 << endl;
cout << fixed;
if ((-b - sqrt(d)) / ((double)2 * a) < (-b + sqrt(d)) / ((double)2 * a)) {
cout << setprecision(9) << (-b - sqrt(d)) / ((double)2 * a) << endl;
cout << setprecision(9) << (-b + sqrt(d)) / ((double)2 * a) << endl;
} else {
cout << setprecision(9) << (-b + sqrt(d)) / ((double)2 * a) << endl;
cout << setprecision(9) << (-b - sqrt(d)) / ((double)2 * a) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MAX = LLONG_MAX, mod = 1000000007, MODA = 1e9 - 1;
const long long MIN = LLONG_MIN;
const long double PI = 3.1415926535;
const long long N = 100009;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0) {
if (c == 0)
cout << -1;
else
cout << 0;
} else if (a == 0) {
cout << fixed << setprecision(8) << "1" << endl << -c / b;
} else {
long double d = b * b - 4 * a * c;
if (d < 0)
cout << 0;
else {
if (d == 0) {
cout << 1 << endl;
long double r = (-b) / (2 * a);
cout << fixed << setprecision(8) << r << endl;
} else if (d > 0) {
cout << 2 << endl;
long double r1 = (-b - sqrt(d)) / (2 * a);
long double r2 = (-b + sqrt(d)) / (2 * a);
cout << fixed << setprecision(8) << min(r1, r2) << endl << max(r1, r2);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
set<double> s;
set<double>::iterator it;
double a, b, c;
cin >> a >> b >> c;
double ans1, ans2;
if (a == 0 && b == 0 && c == 0)
cout << -1 << endl;
else if (a == 0 && b != 0) {
ans2 = -(c / b);
s.insert(ans2);
cout << s.size() << endl;
it == s.begin();
for (it = s.begin(); it != s.end(); it++)
cout << setprecision(5) << fixed << *it << endl;
} else if (a != 0 && b == 0 && c == 0) {
ans1 = 0;
cout << 1 << endl << setprecision(5) << fixed << ans1 << endl;
} else if ((-b) + sqrt(b * b - 4 * a * c) == 0 &&
(-b) - sqrt(b * b - 4 * a * c) == 0)
cout << 0 << endl;
else if ((b * b - 4 * a * c) < 0)
cout << 0 << endl;
else {
ans1 = ((-b) + sqrt(b * b - 4 * a * c)) / (2 * a);
ans2 = ((-b) - sqrt((b * b - 4 * a * c))) / (2 * a);
s.insert(ans1);
s.insert(ans2);
cout << s.size() << endl;
for (it = s.begin(); it != s.end(); it++)
cout << setprecision(5) << fixed << *it << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
if (a == 0 && b != 0) {
cout << 1 << endl;
cout << fixed << setprecision(5) << -1.0 * c / b << endl;
} else if (a != 0 && b == 0) {
double resp = c * 1.0 / a;
if (resp < 0) {
cout << 2 << endl;
cout << fixed << setprecision(5) << -1 * sqrt(resp) << endl;
cout << fixed << setprecision(5) << sqrt(resp) << endl;
} else if (resp > 0) {
cout << 0 << endl;
} else {
cout << 1 << endl;
cout << fixed << setprecision(5) << 0 << endl;
}
} else if (a == 0 && b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else {
if (a != 0 && b != 0) {
long long aux = b * b - 4 * a * c;
if (aux < 0) {
cout << 0 << endl;
} else {
if (aux == 0) {
cout << 1 << endl;
double resp23 = (-b) / (2 * a);
cout << fixed << setprecision(5) << resp23 << endl;
} else {
double tri = sqrt(aux);
double raiz1 = (-b - tri) / (2 * a);
double raiz2 = (-b + tri) / (2 * a);
cout << 2 << endl;
if (raiz2 < raiz1) swap(raiz1, raiz2);
cout << fixed << setprecision(5) << raiz1 << endl;
cout << fixed << setprecision(5) << raiz2 << endl;
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
class Quadratic_root {
long long a, b, c;
public:
Quadratic_root(long a, long b, long c) : a(a), b(b), c(c) {}
void Calculate_roots() {
if ((b * b - 4 * a * c) < 0)
cout << 0 << endl;
else if (!a && !b && !c)
cout << -1 << endl;
else if (!a && !b) {
cout << 0 << endl;
} else if (!a) {
cout << 1 << endl;
cout << fixed << setprecision(10) << (-1 * c) / float(b);
} else {
double ans1 = (-b + sqrt(b * b - 4 * a * c)) / float(2 * a);
double ans2 = (-b - sqrt(b * b - 4 * a * c)) / float(2 * a);
if (ans1 == ans2) {
cout << 1 << endl;
cout << fixed << setprecision(10) << ans1 << endl;
} else {
if (ans2 < ans1) {
double temp = ans1;
ans1 = ans2;
ans2 = temp;
}
cout << 2 << endl;
cout << fixed << setprecision(10) << ans1 << endl;
cout << fixed << setprecision(10) << ans2 << endl;
}
}
}
};
int main() {
long long a, b, c;
cin >> a >> b >> c;
Quadratic_root Q(a, b, c);
Q.Calculate_roots();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
int main() {
cin >> a >> b >> c;
double k = b * b;
double l = 4 * a * c;
if (a == 0) {
if (b == 0 && c == 0) {
cout << -1 << endl;
return 0;
}
if (b == 0 && c != 0) {
cout << 0 << endl;
return 0;
}
if (c == 0) {
cout << 1 << endl;
printf("%.9f", 0);
} else {
cout << 1 << endl;
printf("%.9f", -c / b);
}
} else {
if (k - l < 0)
cout << 0 << endl;
else if (k - l == 0) {
cout << 1 << endl;
printf("%.9f\n", (sqrt(k - l) - b) / 2 / a);
} else if (k - l > 0) {
cout << 2 << endl;
printf("%.9f\n%.9f\n",
((sqrt(k - l) - b) / 2 / a - (-sqrt(k - l) - b) / 2 / a) < 0
? (sqrt(k - l) - b) / 2 / a
: (-sqrt(k - l) - b) / 2 / a,
((sqrt(k - l) - b) / 2 / a - (-sqrt(k - l) - b) / 2 / a) > 0
? (sqrt(k - l) - b) / 2 / a
: (-sqrt(k - l) - b) / 2 / a);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double A, B, C;
const double EPSILON = 1e-6;
cin >> A >> B >> C;
if (fabs(A) < EPSILON) {
if (fabs(B) < EPSILON) {
if (fabs(C) < EPSILON)
cout << -1 << endl;
else
cout << 0 << endl;
} else {
cout << 1 << endl;
double x1 = -C / B;
if (fabs(x1) < EPSILON) x1 = 0;
printf("%.10lf\n", x1);
}
} else {
double det = B * B - 4 * A * C;
if (det < -EPSILON)
cout << 0 << endl;
else {
double x1 = (-B + sqrt(det)) / A / 2;
double x2 = (-B - sqrt(det)) / A / 2;
if (fabs(x1) < EPSILON) x1 = 0;
if (fabs(x2) < EPSILON) x2 = 0;
if (fabs(x1 - x2) < EPSILON) {
cout << 1 << endl;
printf("%.10lf\n", x1);
} else {
cout << 2 << endl;
if (x1 > x2) swap(x1, x2);
printf("%.10lf\n%.10lf\n", x1, x2);
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, x = 4, m = 0, a1, a2, n = 2, ans;
cin >> a >> b >> c;
ans = b * b - x * a * c;
if (a == m && b == m && c == m) {
cout << -1;
return 0;
}
if (a == m && b == m) {
cout << 0;
return 0;
}
if (a == m) {
cout << 1 << endl;
cout << fixed << setprecision(6) << (-c) / (b);
return 0;
}
if (ans < 0) {
cout << 0;
return 0;
}
if (ans == m) {
cout << 1 << endl;
cout << fixed << setprecision(6) << (-b) / (n * a);
return 0;
}
ans = sqrt(ans);
a1 = (-b + ans) / (n * a);
a2 = (-b - ans) / (n * a);
cout << 2 << endl;
if (a1 < a2) {
cout << fixed << setprecision(6) << a1 << endl;
cout << fixed << setprecision(6) << a2 << endl;
} else {
cout << fixed << setprecision(6) << a2 << endl;
cout << fixed << setprecision(6) << a1 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
return 0;
} else {
if (a == 0 && b == 0 && c != 0) {
cout << "0" << endl;
return 0;
} else {
if (a == 0 && b != 0) {
cout << "1" << endl;
cout << fixed << setprecision(12) << -(c / b) << endl;
return 0;
} else {
if (a != 0) {
long double d = (b * b) - (4 * (a * c));
long double r1, r2;
if (d > 0) {
cout << "2" << endl;
d = sqrtl(d);
r1 = ((d - b) / 2) / a;
r2 = -(((d + b) / 2)) / a;
if (r1 > r2) {
cout << fixed << setprecision(12) << r2 << endl;
cout << fixed << setprecision(12) << r1 << endl;
} else {
cout << fixed << setprecision(12) << r1 << endl;
cout << fixed << setprecision(12) << r2 << endl;
}
return 0;
}
if (d == 0) {
cout << "1" << endl;
cout << fixed << setprecision(12) << -((b / 2) / a) << endl;
return 0;
}
if (d < 0) {
cout << "0" << endl;
}
}
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
if (a != 0 && b != 0 && c != 0) {
long long d = b * b - 4 * a * c;
if (d < 0) {
cout << 0;
return 0;
}
long double r = sqrt(d), one = 1.0 * (-b - r) / (2 * a),
two = 1.0 * (-b + r) / (2 * a);
if (d == 0) {
cout << fixed << setprecision(7) << "1\n" << one;
return 0;
}
if (one < two) {
cout << fixed << setprecision(7) << "2\n" << one << "\n" << two << "\n";
} else {
cout << fixed << setprecision(7) << "2\n" << two << "\n" << one << "\n";
}
return 0;
}
if (a == 0 && b != 0 && c != 0) {
long double one = 1.0 * (-c) / b;
cout << fixed << setprecision(7) << "1\n" << one;
return 0;
}
if (a != 0 && b == 0 && c != 0) {
if (c > 0) {
cout << 0;
return 0;
}
long double one = sqrt((c / a)), two = -one;
if (one < two) {
cout << fixed << setprecision(7) << "2\n" << one << "\n" << two;
} else {
cout << fixed << setprecision(7) << "2\n" << two << "\n" << one;
}
return 0;
}
if (a != 0 && b != 0 && c == 0) {
long double one = 0.0, two = 1.0 * (-b) / a;
if (one < two) {
cout << fixed << setprecision(7) << "2\n" << one << "\n" << two;
} else {
cout << fixed << setprecision(7) << "2\n" << two << "\n" << one;
}
return 0;
}
if (a == 0 && b == 0 && c != 0) {
cout << 0;
return 0;
}
if (a == 0 && b != 0 && c == 0) {
cout << fixed << setprecision(7) << "1\n" << 0.000000000;
return 0;
}
if (a != 0 && b == 0 && c == 0) {
cout << fixed << setprecision(7) << "1\n" << 0.00000000;
return 0;
}
if (a == 0 && b == 0 && c == 0) {
cout << "-1";
return 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
int main() {
int a, b, c;
double delta;
double A, B, C;
long long aa, bb, cc;
while (scanf("%d %d %d", &a, &b, &c) != EOF) {
if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
continue;
}
if (a == 0 && b == 0) {
printf("0\n");
continue;
}
B = b;
C = c;
if (a == 0) {
printf("1\n");
printf("%.10lf\n", -C / B);
continue;
}
A = a;
aa = a;
bb = b;
cc = c;
if (bb * bb - 4LL * aa * cc < 0) {
printf("0\n");
continue;
}
if (bb * bb - 4LL * aa * cc == 0) {
printf("1\n");
printf("%.10lf\n", -B / A / 2.0);
continue;
}
delta = B * B - 4 * A * C;
printf("2\n");
if (a < 0) {
printf("%.10lf\n", (-B + sqrt(delta)) / A / 2.0);
printf("%.10lf\n", (-B - sqrt(delta)) / A / 2.0);
} else {
printf("%.10lf\n", (-B - sqrt(delta)) / A / 2.0);
printf("%.10lf\n", (-B + sqrt(delta)) / A / 2.0);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<double> roots;
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
return 0;
}
if (a == 0 && b == 0 && c != 0) {
printf("0\n");
return 0;
}
if (a == 0) {
printf("1\n");
printf("%.5lf\n", -c / b);
return 0;
}
if (b * b < 4 * a * c) {
printf("0\n");
return 0;
}
roots.push_back((-b + sqrt(b * b - 4 * a * c)) / (2 * a));
if ((-b + sqrt(b * b - 4 * a * c)) / (2 * a) !=
(-b - sqrt(b * b - 4 * a * c)) / (2 * a))
roots.push_back((-b - sqrt(b * b - 4 * a * c)) / (2 * a));
sort(roots.begin(), roots.end());
printf("%d\n", roots.size());
for (int i = 0; i < roots.size(); i++) printf("%.5lf\n", roots[i]);
return 0;
}
|
#include <bits/stdc++.h>
const int N = 200010;
const int inf = 0x3f3f3f3f;
using namespace std;
string str;
long long a, b, c;
int main() {
cin >> a >> b >> c;
if (a == 0) {
if (c == 0) {
if (b == 0) return puts("-1"), 0;
printf("1\n0.000000000000\n");
return 0;
} else {
if (b == 0) return puts("0"), 0;
printf("1\n%.12f\n", -1.0 * c / b);
return 0;
}
} else {
long long x = b * b - 4 * a * c;
if (x < 0) return puts("0"), 0;
if (x == 0) return printf("1\n%.12f\n", -1.0 * b / (2 * a)), 0;
double x1 = (-1.0 * b - sqrt(x + 0.0)) / (2 * a),
x2 = (-1.0 * b + sqrt(x + 0.0)) / (2 * a);
if (x1 > x2) swap(x1, x2);
printf("2\n%.12f\n%.12f\n", x1, x2);
return 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double a, b, c, delta, x1, x2;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << -1;
return 0;
}
if (a == 0 && b == 0 && c != 0) {
cout << 0;
return 0;
}
if (a == 0 && b != 0) {
cout << "1\n" << fixed << setprecision(10) << -c / b;
return 0;
}
delta = b * b - 4 * a * c;
if (delta < 0) {
cout << 0;
return 0;
}
if (delta == 0) {
cout << "1\n" << fixed << setprecision(10) << -b / (2 * a);
return 0;
}
if (delta > 0) {
cout << "2\n";
x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
cout << fixed << setprecision(10) << min(x1, x2) << endl
<< fixed << setprecision(10) << max(x1, x2);
return 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long INT = 1e9;
const long long LONG = 1e18;
const long long mod = 1e9 + 7;
int main() {
double a, b, c;
cin >> a >> b >> c;
double d = b * b - 4 * a * c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1;
else
cout << 0;
} else {
cout << 1 << '\n';
cout << setprecision(9) << fixed << -c / b;
}
return 0;
}
if (d < 0) cout << 0;
if (d == 0) {
cout << 1 << '\n';
cout << setprecision(9) << fixed << -b / (2 * a);
}
if (d > 0) {
cout << 2 << '\n';
double x1 = (-b - sqrt(d)) / (2 * a), x2 = (-b + sqrt(d)) / (2 * a);
cout << setprecision(9) << fixed << min(x1, x2) << '\n';
cout << setprecision(9) << fixed << max(x1, x2) << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if (a != 0) {
double d = b * b - 4 * a * c;
if (d > 0) {
double x1 = (-b - sqrt(d)) / (2 * a), x2 = (-b + sqrt(d)) / (2 * a);
if (x1 > x2) swap(x1, x2);
printf("2\n%.9f\n%.9f\n", x1, x2);
} else if (d == 0)
printf("1\n%.9f\n", -b / (2 * a));
else
printf("0\n");
} else {
if (b != 0)
printf("1\n%.9f\n", -c / b);
else {
if (c != 0)
printf("0\n");
else
printf("-1\n");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double A, B, C;
cin >> A >> B >> C;
double a, b, d;
if (A == 0 && B == 0 && C == 0)
cout << -1;
else if (A > 0 || A < 0) {
if (B * B > 4 * A * C) {
d = B * B - (4 * A * C);
a = (-B + sqrt(d)) / (2 * A);
b = (-B - sqrt(d)) / (2 * A);
cout << 2 << endl;
printf("%.7lf\n", min(a, b));
printf("%.7lf\n", max(a, b));
} else if (B * B == 4 * A * C) {
b = (-B) / (2 * A);
printf("1\n%.7lf\n", b);
} else
cout << 0;
} else {
if (B > 0 || B < 0) {
a = -C / B;
printf("1\n%.7lf\n", a);
} else
cout << 0;
}
}
|
#include <bits/stdc++.h>
int nextInt() {
int x;
scanf("%d", &x);
return x;
}
double nextDouble() {
double x;
scanf("%lf", &x);
return x;
}
long long nextLong() {
long long x;
scanf("%I64d", &x);
return x;
}
char nextChar() {
char x;
scanf("%c", &x);
return x;
}
void newLine() { printf("\n"); }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long pow(long long a, long long b, long long MOD) {
long long x = 1, y = a;
while (b > 0) {
if (b % 2 == 1) {
x = (x * y);
if (x > MOD) x %= MOD;
}
y = (y * y);
if (y > MOD) y %= MOD;
b /= 2;
}
return x;
}
int countSetBit(long long n) {
int ans = 0;
while (n != 0) {
n -= (n & -n);
++ans;
}
return ans;
}
long long mod = 1e9 + 7;
const int N = 30;
const int M = 55;
const double eps = 1e-6;
using namespace std;
int dp[N][N] = {0};
int g[N][N];
int main() {
double a, b, c;
cin >> a >> b >> c;
cout << fixed << setprecision(10);
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
return 0;
}
if (a == 0 && b == 0 && c != 0) {
cout << 0 << endl;
return 0;
}
if (a == 0 && b != 0) {
cout << "1\n" << -c / b << endl;
return 0;
}
if (a != 0 && b == 0) {
if (-1.0 * c / a == 0)
cout << "1\n0.000000" << endl;
else if (-1.0 * c / a < 0)
cout << 0 << endl;
else
cout << "2\n"
<< sqrt(-1.0 * c / a) << "\n"
<< -1.0 * sqrt(-1.0 * c / a) << endl;
return 0;
}
double delta = b * b - 4 * a * c;
if (delta < 0) {
cout << 0 << endl;
return 0;
}
double sq = sqrt(delta);
double x1 = (-b - sq) / (2 * a);
double x2 = (-b + sq) / (2 * a);
if (x1 - x2 > eps) swap(x1, x2);
if (delta == 0)
cout << "1\n" << x1 << endl;
else {
cout << "2\n" << x1 << "\n" << x2 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
long double a, b, c, p, q, r;
cin >> a >> b >> c;
p = b * b - 4 * a * c;
if (a == 0 && b == 0 && c == 0)
cout << -1 << endl;
else if (a == 0 && b == 0 && c != 0)
cout << 0 << endl;
else if (p < 0)
cout << 0 << endl;
else if (a == 0) {
q = -c / b;
cout << 1 << endl;
cout << fixed << setprecision(6) << q;
} else if (p == 0) {
q = -b / (2 * a);
cout << 1 << endl;
cout << fixed << setprecision(6) << q;
} else {
q = (-b - sqrt(p)) / (2 * a);
r = (-b + sqrt(p)) / (2 * a);
if (q < r) {
cout << 2 << '\n' << fixed << setprecision(6) << q << endl;
cout << fixed << setprecision(6) << r << endl;
} else {
cout << 2 << '\n' << fixed << setprecision(6) << r << endl;
cout << fixed << setprecision(6) << q << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long tt = 1;
while (tt--) {
long long a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
} else if (a == 0 && b == 0) {
cout << 0 << endl;
} else if (a == 0) {
cout << 1 << endl;
cout << fixed << setprecision(12) << ((-1.0 * c) / b) << endl;
} else {
long long d = b * b - 4 * a * c;
if (d < 0)
cout << 0 << endl;
else if (d == 0) {
cout << 1 << endl;
cout << fixed << setprecision(12) << ((-1.0 * b) / (2.0 * a)) << endl;
} else {
long double rt = sqrt(d);
cout << 2 << endl;
if (a > 0) {
cout << fixed << setprecision(12) << ((-1.0 * b - rt) / (2.0 * a))
<< endl;
cout << fixed << setprecision(12) << ((-1.0 * b + rt) / (2.0 * a))
<< endl;
} else {
cout << fixed << setprecision(12) << ((-1.0 * b + rt) / (2.0 * a))
<< endl;
cout << fixed << setprecision(12) << ((-1.0 * b - rt) / (2.0 * a))
<< endl;
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const bool online_judge = true;
const long long inf = 1LL << 60;
long long toInt(string s) {
long long res;
stringstream ss;
ss << s;
ss >> res;
return res;
}
string toString(long long n) {
stringstream ss;
ss << n;
return ss.str();
}
double EPS = 1e-9;
void run() {
long long a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
return;
}
if (a == 0) {
cout << 1 << endl;
cout << fixed << setprecision(7) << (double)c / b * (-1);
return;
}
long long D = b * b - 4 * a * c;
if (D < 0) {
cout << 0 << endl;
return;
}
if (D == 0) {
cout << 1 << endl;
cout << (double)-b / (2 * a);
return;
}
double d = sqrt(D);
cout << 2 << endl;
auto ans = {(double)(-b - d) / (2 * a), (double)(-b + d) / (2 * a)};
cout << fixed << setprecision(7) << min(ans) << endl;
cout << max(ans) << endl;
}
int main(int argc, char *argv[]) {
run();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long A, B, C;
cin >> A >> B >> C;
if (A == 0) {
if (B == 0) {
if (C == 0) {
cout << -1 << endl;
} else {
cout << 0 << endl;
}
} else {
double x = -1.0 * C / B;
cout << 1 << endl;
cout << fixed << setprecision(5) << x << endl;
}
} else {
long long disc = B * B - 4 * A * C;
if (disc < 0) {
cout << 0 << endl;
} else {
if (disc == 0) {
cout << 1 << endl;
double x = -1.0 * B / (2 * A);
cout << fixed << setprecision(5) << x << endl;
} else {
cout << 2 << endl;
double x1 = (-B + sqrt(disc)) / (2.0 * A);
double x2 = (-B - sqrt(disc)) / (2.0 * A);
if (x1 > x2) {
swap(x1, x2);
}
cout << fixed << setprecision(5) << x1 << endl << x2 << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c, x, x1, x2, d;
int main() {
cin >> a >> b >> c;
d = b * b - 4 * a * c;
if (a == 0 && b == 0 && c != 0) {
cout << 0 << endl;
return 0;
}
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
return 0;
}
if (a == 0 && b != 0) {
cout << 1 << endl;
printf("%.5f", (-c) / b);
return 0;
}
if (d == 0) {
cout << 1 << endl;
x = (-b + sqrt(d)) / (2 * a);
printf("%.5f", x);
return 0;
}
if (d < 0) {
cout << 0;
return 0;
}
cout << 2 << endl;
x2 = (-b + sqrt(d)) / (2 * a);
x1 = (-b - sqrt(d)) / (2 * a);
if (x1 > x2) swap(x1, x2);
printf("%.5f\n", x1);
printf("%.5f\n", x2);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
double a, b, c, d, e, f;
cin >> a >> b >> c;
d = pow(b, 2) - (4 * a * c);
if (d < 0) {
cout << 0;
} else if (a == 0 and b == 0 and c == 0) {
cout << -1 << endl;
} else if (a == 0 and b == 0 and c != 0) {
cout << 0 << endl;
} else if (a == 0 and b != 0) {
cout << 1 << endl;
cout << setprecision(25) << double((-1 * c) / b) << endl;
} else {
e = ((-1 * b) + pow(d, 0.5)) / (2 * a);
f = ((-1 * b) - pow(d, 0.5)) / (2 * a);
if (d == 0) {
cout << 1 << endl;
cout << setprecision(25) << e << endl;
} else {
cout << 2 << endl;
if (e < f) {
cout << setprecision(25) << e << endl;
cout << setprecision(25) << f << endl;
} else {
cout << setprecision(25) << f << endl;
cout << setprecision(25) << e << endl;
}
}
}
}
|
#include <bits/stdc++.h>
#pragma GCC target("sse4,avx")
void run(std::istream& in, std::ostream& out) {
int A, B, C;
in >> A >> B >> C;
out.precision(20);
if (A == 0) {
if (B == 0) {
if (C == 0) {
out << -1 << std::endl;
return;
}
out << 0 << std::endl;
return;
}
out << 1 << std::endl;
out << (double)-C / B << std::endl;
return;
}
int64_t D = int64_t(B) * B - int64_t(A) * C * 4;
if (D < 0) {
out << 0 << std::endl;
return;
}
if (D == 0) {
out << 1 << std::endl;
out << -(double)B / (2 * A) << std::endl;
return;
}
out << 2 << std::endl;
double x1 = (-(double)B - sqrt(D)) / (2 * A);
double x2 = (-(double)B + sqrt(D)) / (2 * A);
if (x1 > x2) std::swap(x1, x2);
out << x1 << std::endl;
out << x2 << std::endl;
}
int main() {
std::cin.sync_with_stdio(false);
std::cin.tie(nullptr);
run(std::cin, std::cout);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
double x1, x2;
cin >> a >> b >> c;
if (a == 0 && b == 0) {
if (c == 0)
printf("-1\n");
else
printf("0\n");
} else if (a == 0 && c == 0) {
printf("1\n0\n");
} else if (b == 0 && c == 0) {
printf("1\n0\n");
} else if (a == 0) {
printf("1\n");
printf("%.10lf\n", -c / b);
} else {
double tem = b * b - 4 * a * c;
if (tem < 0)
printf("0\n");
else if (tem == 0) {
printf("1\n");
printf("%.6lf\n", (-b / (2 * a)));
} else {
printf("2\n");
x1 = (-b + (sqrt(b * b - 4 * a * c))) / (2 * a);
x2 = (-b - (sqrt(b * b - 4 * a * c))) / (2 * a);
if (x1 < x2) {
printf("%.10lf\n%.10lf\n", x1, x2);
} else {
printf("%.10lf\n%.10lf\n", x2, x1);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
scanf("%lf %lf %lf", &a, &b, &c);
if (a != 0 && b != 0 && c != 0) {
if (((b * b) - (4 * a * c)) == 0) {
printf("1\n");
printf("%lf", -b / (2 * a));
} else if (((b * b) - (4 * a * c)) > 0) {
printf("2\n");
if ((-b - sqrt(((b * b) - (4 * a * c)))) / (2 * a) <
(-b + sqrt(((b * b) - (4 * a * c)))) / (2 * a)) {
printf("%lf\n%lf", (-b - sqrt(((b * b) - (4 * a * c)))) / (2 * a),
(-b + sqrt(((b * b) - (4 * a * c)))) / (2 * a));
} else {
printf("%lf\n%lf", (-b + sqrt(((b * b) - (4 * a * c)))) / (2 * a),
(-b - sqrt(((b * b) - (4 * a * c)))) / (2 * a));
}
}
if (((b * b) - (4 * a * c)) < 0) {
printf("0\n");
}
}
if (a == 0 && b != 0 && c != 0) {
printf("1\n");
printf("%lf", -c / b);
}
if (a != 0 && b == 0 && c > 0) {
printf("0\n");
}
if (a != 0 && b != 0 && c == 0) {
printf("2\n");
if (0 < (-b / a)) {
printf("0.000000\n%lf", -b / a);
} else {
printf("%lf\n0.000000", -b / a);
}
}
if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
}
if (a == 0 && b == 0 && c != 0) {
printf("0\n");
}
if (a == 0 && b != 0 && c == 0) {
printf("1\n");
printf("0\n");
}
if ((a > 0 || a < 0) && b == 0 && c == 0) {
printf("1\n");
printf("0.000000");
}
if (a != 0 && b == 0 && c < 0) {
printf("2\n");
if (sqrt(-c / a) < -sqrt(-c / a)) {
printf("%lf\n%lf", sqrt(-c / a), -sqrt(-c / a));
} else {
printf("%lf\n%lf", -sqrt(-c / a), sqrt(-c / a));
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int INF = 2147483647;
const long long LINF = 9223372036854775807;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
double a, b, c;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> a >> b >> c;
if (a == 0) {
if (b != 0)
printf("1\n%.10lf", -c / b);
else if (c == 0)
printf("-1");
else
printf("0");
} else {
double delta = b * b - 4 * a * c;
if (delta < 0)
printf("0");
else if (delta == 0)
printf("1\n%.10lf", -b / (2 * a));
else
printf("2\n%.10lf %.10lf",
min((-b + sqrt(delta)) / (2 * a), (-b - sqrt(delta)) / (2 * a)),
max((-b + sqrt(delta)) / (2 * a), (-b - sqrt(delta)) / (2 * a)));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b != 0) {
cout << 1 << endl;
long double ans = (long double)(-c / b);
cout << fixed << setprecision(10) << ans << endl;
return 0;
}
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
return 0;
}
if (a == 0 && b == 0 && c != 0) {
cout << 0 << endl;
return 0;
}
if (b * b - 4 * a * c == 0) {
cout << 1 << endl;
long long int ans = (long double)((-b / (2 * a)));
cout << fixed << setprecision(10) << ans << endl;
return 0;
} else if (b * b - 4 * a * c < 0) {
cout << 0 << endl;
return 0;
} else {
long double x, y;
x = (long double)((-b + (long double)sqrt(b * b - 4 * a * c)) / (2 * a));
y = (long double)((-b - (long double)sqrt(b * b - 4 * a * c)) / (2 * a));
cout << 2 << endl;
if (x > y) {
swap(x, y);
}
cout << fixed << setprecision(10) << x << endl;
cout << fixed << setprecision(10) << y << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0 && b == 0 && c == 0) {
printf("-1");
return 0;
} else if (a == 0 && b == 0) {
printf("0");
return 0;
} else if (b == 0 && c == 0) {
printf("1\n%lf", 0);
return 0;
} else if (a == 0 && c == 0) {
printf("1\n%lf", 0);
return 0;
} else if (a == 0) {
printf("1\n%lf", (-c / b));
return 0;
} else if (b == 0) {
if ((-c / a) < 0) {
printf("0");
return 0;
}
printf("2\n%lf %lf", (-sqrt(-c / a)), (sqrt(-c / a)));
return 0;
} else if (c == 0) {
if ((b / a) < 0) {
printf("2\n0.000000 %lf", (-b / a));
return 0;
} else {
printf("2\n%lf 0.000000", (-b / a));
return 0;
}
} else {
if (b * b - 4 * a * c < 0) {
printf("0");
return 0;
}
double p, q;
p = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
q = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
if (p == q) {
printf("1\n%lf", q);
return 0;
}
if (p > q) {
double temp;
temp = q;
q = p;
p = temp;
}
printf("2\n%lf %lf", p, q);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
set<double> s;
double d = b * b - 4 * a * c;
if (d < 0) {
cout << "0" << endl;
} else if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
} else {
double a1, a2;
if (a != 0) {
a1 = (-b + sqrt(d)) / (2.0 * a);
a2 = (-b - sqrt(d)) / (2.0 * a);
s.insert(a1);
s.insert(a2);
cout << s.size() << endl;
for (auto i = s.begin(); i != s.end(); i++) {
printf("%.15lf\n", *i);
}
} else if (b != 0) {
a1 = (a2 = -c / b);
s.insert(a1);
s.insert(a2);
cout << s.size() << endl;
for (auto i = s.begin(); i != s.end(); i++) {
printf("%.15lf\n", *i);
}
} else {
cout << "0" << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double min(double a, double b) { return a < b ? a : b; }
double max(double a, double b) { return a > b ? a : b; }
int main() {
double a, b, c, x1, x2, dlta;
int num;
while (cin >> a >> b >> c) {
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
continue;
}
if (a == 0 && b == 0 && c != 0) {
cout << '0' << endl;
continue;
}
if (a == 0 && b != 0) {
x1 = (-1 * c) / b;
num = 1;
cout << num << endl;
printf("%.10lf\n", x1);
continue;
}
if (a != 0) {
dlta = b * b - 4 * a * c;
if (dlta > 0) {
x1 = (-b + sqrt(dlta)) / (2 * a);
x2 = (-b - sqrt(dlta)) / (2 * a);
num = 2;
cout << num << endl;
printf("%.10lf\n%.10lf\n", min(x1, x2), max(x1, x2));
continue;
}
if (dlta == 0) {
x1 = -b / (2 * a);
cout << '1' << endl;
printf("%.10lf\n", x1);
continue;
}
if (dlta < 0) {
cout << '0' << endl;
continue;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d;
int main() {
scanf("%lld%lld%lld", &a, &b, &c);
if (a) {
if (a < 0) a = -a, b = -b, c = -c;
d = b * b - 4 * a * c;
if (d > 0)
printf("2\n%.10lf\n%.10lf\n", (-b - sqrt((double)d)) / (2 * a),
(-b + sqrt((double)d)) / (2 * a));
else if (d < 0)
printf("0\n");
else
printf("1\n%.10lf\n", (double)-b / (2 * a));
} else if (b)
printf("1\n%.10lf\n", (double)-c / b);
else if (c)
printf("0\n");
else
printf("-1\n");
return 0;
}
|
#include <bits/stdc++.h>
int main() {
double a, b, c, p, root1, root2;
scanf(" %lf%lf%lf", &a, &b, &c);
if (a != 0) {
p = b * b - 4 * a * c;
if (p < 0)
printf("0\n");
else {
if (p == 0) {
printf("1\n");
root1 = -b / (2 * a);
printf("%.6lf", root1);
} else {
printf("2\n");
p = sqrt(p);
root1 = (-b - p) / (2 * a);
root2 = (-b + p) / (2 * a);
if (root1 < root2) {
printf("%.6lf\n", root1);
printf("%.6lf\n", root2);
} else {
printf("%.6lf\n", root2);
printf("%.6lf\n", root1);
}
}
}
} else {
if (b != 0) {
root1 = -c / b;
printf("1\n");
printf("%.6lf", root1);
} else {
if (c == 0)
printf("-1\n");
else
printf("0\n");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using lim = numeric_limits<T>;
template <typename T>
istream& operator>>(istream& is, vector<T>& a) {
for (T& x : a) {
is >> x;
}
return is;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll a, b, c;
cin >> a >> b >> c;
cout.setf(ios::fixed);
cout.precision(5);
if (a == 0) {
if (b == 0) {
cout << (c == 0 ? -1 : 0) << endl;
} else {
cout << 1 << endl;
cout << (double)-c / b << endl;
}
} else {
ll d = b * b - 4 * a * c;
if (d > 0) {
cout << 2 << endl;
double r1 = (-b - sqrtl(d)) / (2 * a), r2 = (-b + sqrtl(d)) / (2 * a);
cout << min(r1, r2) << endl;
cout << max(r1, r2) << endl;
} else if (d == 0) {
cout << 1 << endl;
cout << (double)-b / (2 * a) << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d;
while (cin >> a >> b >> c) {
d = b * b - 4 * a * c;
if (!a && !b && !c) {
cout << -1 << endl;
continue;
}
if ((!a && !b && c) || d < 0) {
cout << 0 << endl;
continue;
}
if (!a && b) {
printf("1\n%.9lf\n", (-c) / b);
continue;
}
if (a > 0) {
if (d > 0) {
printf("2\n%.9lf\n%.9lf\n", ((-b - sqrt(d)) / (2 * a)),
((-b + sqrt(d)) / (2 * a)));
continue;
}
} else {
if (d > 0)
printf("2\n%.9lf\n%.9lf\n", ((b - sqrt(d)) / (-2 * a)),
((b + sqrt(d)) / (-2 * a)));
}
if (d == 0) {
printf("1\n%.9lf\n", (-b) / (2 * a));
continue;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d;
cin >> a >> b >> c;
d = b * b - 4 * a * c;
if (a == 0 && b == 0 && c == 0)
printf("-1\n");
else if (a == 0 && b == 0 && c != 0)
printf("0\n");
else if (a == 0)
printf("1\n%f\n", -(c / b));
else if (d < 0)
printf("0\n");
else if (d == 0)
printf("1\n%.9f\n", -b / (2 * a));
else if (a > 0)
printf("2\n%.9f\n%.9f\n", (-b - sqrt(d)) / 2 / a, (-b + sqrt(d)) / (2 * a));
else
printf("2\n%.9f\n%.9f\n", (-b + sqrt(d)) / 2 / a, (-b - sqrt(d)) / (2 * a));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
double d = b * b - a * c * 4;
double x1 = (-b + sqrt(d)) / (2 * a);
double x2 = (-b - sqrt(d)) / (2 * a);
if (d < 0) {
cout << 0;
} else if (a == 0 && b == 0 && c != 0) {
cout << 0;
} else if (a == 0 && b == 0 && c == 0) {
cout << -1;
} else if (a == 0) {
cout << 1 << "\n" << fixed << setprecision(7) << -(double)c / b;
} else if (x1 > x2) {
cout << 2 << "\n";
cout << fixed;
cout << setprecision(7) << x2 << "\n";
cout << setprecision(7) << x1;
} else if (x1 < x2) {
cout << 2 << "\n";
cout << fixed;
cout << setprecision(7) << x1 << "\n";
cout << setprecision(7) << x2;
} else if (x1 == x2) {
cout << 1 << "\n";
cout << fixed;
cout << setprecision(7) << x1;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using uint = uint32_t;
using ull = uint64_t;
using ld = long double;
using ll = int64_t;
template <typename T>
int cmp(const T &a, const T &b) {
return ((a + 1e-9 < b) ? -1 : ((b + 1e-9 < a) ? 1 : 0));
}
class Task {
private:
ld A, B, C;
void degree2() {
ld sq = B * B - 4 * A * C;
ld rt1, rt2;
if (cmp(sq, ld(0)) < 0) {
cout << 0 << '\n';
} else if (cmp(sq, ld(0)) == 0) {
cout << 1 << '\n';
rt1 = -B / (2.0 * A);
cout << fixed << setprecision(10) << rt1 << '\n';
} else {
cout << 2 << '\n';
rt1 = ld(ld(-B) + sqrt(sq)) / ld(2 * A);
rt2 = ld(ld(-B) - sqrt(sq)) / ld(2 * A);
vector<ld> ans(2);
ans[0] = rt1;
ans[1] = rt2;
sort(ans.begin(), ans.end());
cout << fixed << setprecision(10) << ans[0] << '\n';
cout << fixed << setprecision(10) << ans[1] << '\n';
}
return;
}
void degree1() {
int sq = B * B - 4 * A * C;
ld rt1, rt2;
cout << 1 << '\n';
cout << fixed << setprecision(10) << (-ld(C) / ld(B)) << '\n';
}
void solveOne(istream &in, ostream &out) {
in >> A >> B >> C;
int sq = B * B - 4 * A * C;
ld rt1, rt2;
if (A)
degree2();
else {
if (B) {
degree1();
} else {
if (C) {
cout << (0) << '\n';
return;
} else {
cout << (-1) << '\n';
return;
};
}
}
}
public:
void solve(istream &in, ostream &out) {
int t = 1;
while (t--) solveOne(in, out);
}
};
auto main() -> int {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
Task solver;
istream &in(cin);
ostream &out(cout);
solver.solve(in, out);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, b, c;
double x, s, x1, x2;
long long int l;
while (~scanf("%lld%lld%lld", &a, &b, &c)) {
if (a == 0 && b == 0 && c == 0)
printf("-1\n");
else if (a == 0 && b == 0)
printf("0\n");
else if (b == 0 && c == 0)
printf("1\n0\n");
else if (a == 0 && c == 0)
printf("1\n0\n");
else if (a == 0) {
x = -1.0 * c / b;
printf("1\n%.10lf\n", x);
} else if (b == 0) {
s = -1.0 * c / a;
if (s < 0)
printf("0\n");
else {
x = sqrt(s);
printf("2\n%.10lf\n%.10lf\n", -x, x);
}
} else if (c == 0) {
x = -1.0 * b / a;
if (x > 0)
printf("2\n0\n%.10lf\n", x);
else
printf("2\n%.10lf\n0\n", x);
} else {
l = b * b - 4 * a * c;
if (l < 0)
printf("0\n");
else if (l == 0)
printf("1\n%.10lf\n", -1.0 * b / 2 / a);
else {
x1 = 1.0 * (-b - sqrt(l)) / 2 / a;
x2 = 1.0 * (-b + sqrt(l)) / 2 / a;
if (x2 - x1 > 1e-10)
printf("2\n%.10lf\n%.10lf\n", x1, x2);
else
printf("2\n%.10lf\n%.10lf\n", x2, x1);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
double min(double a, double b) {
if (a > b) return b;
return a;
}
double max(double a, double b) {
if (a < b) return b;
return a;
}
int main() {
double t, x1, x2;
while (scanf("%lf %lf %lf", &a, &b, &c) != EOF) {
if (a == 0 && b == 0 && c == 0) puts("-1");
if (a == 0 && b == 0 && c != 0) puts("0");
if (a == 0 && b != 0) {
puts("1");
printf("%.10lf\n", -c / b);
}
if (a != 0) {
t = b * b - 4 * a * c;
if (t == 0) {
puts("1");
x1 = (-b / (2 * a));
printf("%.10lf\n", x1);
} else if (t > 0) {
puts("2");
x1 = min((-b - sqrt(t)) / (2 * a), (-b + sqrt(t)) / (2 * a));
x2 = max((-b - sqrt(t)) / (2 * a), (-b + sqrt(t)) / (2 * a));
printf("%.10lf\n%.10lf\n", x1, x2);
} else if (t < 0) {
puts("0");
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 200005;
vector<long long int> adj[maxn];
long long int a[maxn], jvb[maxn];
int main() {
ios_base::sync_with_stdio(false);
double a, b, c, delta = 0;
cin >> a >> b >> c;
double rt1, rt2;
cout << fixed << setprecision(12);
if (a == 0 && b == 0) {
if (c == 0) {
cout << "-1";
} else
cout << '0';
return 0;
}
if (a == 0) {
cout << '1' << "\n" << -c / b;
return 0;
}
delta = (b * b) - ((double)4 * a * c);
delta = sqrt(delta);
if (delta < 0) {
cout << '0';
return 0;
}
rt1 = (((double)-1 * b) + delta) / ((double)2 * a);
rt2 = (((double)-1 * b) - delta) / ((double)2 * a);
if (delta == 0) {
cout << '1' << "\n";
cout << rt1;
return 0;
}
if (rt1 > rt2) swap(rt1, rt2);
cout << '2' << "\n" << rt1 << "\n" << rt2;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int r, j, l, x, y, m, c, n, s, f, q, i, z, p, k, d, t, u, e, g, w;
string s1, s2, s3, s4;
int main() {
cin >> x >> y >> z;
if (x == 0) {
if (y == 0) {
if (z == 0)
cout << -1;
else
cout << 0;
} else {
printf("1\n");
double d = -(z * 1.0) / (y * 1.0);
printf("%.9f", d);
}
} else if (y == 0) {
p = x * z;
if (p > 0)
cout << 0;
else if (p == 0) {
cout << "1\n0.00000000";
} else {
printf("2\n");
double d = abs(z * 1.0 / (x * 1.00));
d = sqrt(d);
printf("%.9f\n%.9f", -d, d);
}
} else {
p = y * y - (4 * x * z);
if (p < 0)
cout << 0;
else if (p == 0) {
cout << "1\n";
double d = -(y * 1.00) / (2 * x * 1.000);
printf("%.9f", d);
} else {
double d = sqrt((double)(p * 1.0000));
double d1 = (-y + d) / (2 * x * 1.00);
double d2 = (-y - d) / (2 * x * 1.00);
cout << "2\n";
if (d1 < d2)
printf("%.9f\n%.9f", d1, d2);
else
printf("%.9f\n%.9f", d2, d1);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d;
double ans, ans1, ans2;
int main() {
scanf("%I64d %I64d %I64d", &a, &b, &c);
if (a == 0) {
if (b == 0) {
if (c == 0) {
puts("-1");
} else {
puts("0");
}
} else {
puts("1");
ans = (double)(-c) / (double)(b);
printf("%.12lf\n", ans);
}
} else {
d = b * b - 4 * a * c;
if (d < 0) {
puts("0");
} else if (d == 0) {
puts("1");
ans = (double)(-b) / (double)(2 * a);
printf("%.12lf\n", ans);
} else {
puts("2");
ans1 = ((double)(-b) + sqrt((double)(d))) / (double)(2 * a);
ans2 = ((double)(-b) - sqrt((double)(d))) / (double)(2 * a);
if (ans2 < ans1) {
swap(ans1, ans2);
}
printf("%.12lf\n%.12lf\n", ans1, ans2);
}
}
return 0;
}
|
#include <bits/stdc++.h>
long long A, B, C, D;
int main() {
std ::cin >> A >> B >> C;
D = B * B - 4 * A * C;
if (A == 0 && B == 0 && C == 0)
printf("-1\n");
else if (A == 0 && B == 0 && C != 0)
printf("0\n");
else if (A == 0)
printf("1\n%lf\n", -(double)C / B);
else if (D < 0)
printf("0\n");
else if (D == 0)
printf("1\n%.9lf\n", -B * 1.0 / 2 / A);
else if (A > 0)
printf("2\n%.9lf\n%.9lf\n", (-B - sqrt(D)) * 1.0 / 2 / A,
(-B + sqrt(D)) * 1.0 / 2 / A);
else
printf("2\n%.9lf\n%.9lf\n", (-B + sqrt(D)) * 1.0 / 2 / A,
(-B - sqrt(D)) * 1.0 / 2 / A);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.