solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
from math import sqrt
abc = input().split()
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])
if a == 0:
if b == 0:
if c == 0:
print("-1")
else:
print("0")
else:
print("1")
print(-c/b)
else:
if b**2-4*a*c < 0:
print("0")
elif b**2-4*a*c == 0:
print("1")
print(-b/2/a)
else:
print("2")
p1 = min((-b+sqrt(b**2-4*a*c))/2/a,(-b-sqrt(b**2-4*a*c))/2/a)
p2 = max((-b+sqrt(b**2-4*a*c))/2/a,(-b-sqrt(b**2-4*a*c))/2/a)
print("{:.6f}".format(p1))
print("{:.6f}".format(p2))
| 8 |
PYTHON3
|
#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);
}
| 8 |
CPP
|
#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;
}
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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));
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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);
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
from math import *
from decimal import *
getcontext().prec = 10
a, b, c = input().strip().split()
a, b, c = [int(a), int(b), int(c)]
d = b**2 - 4*a*c
if a == 0 and b == 0 and c == 0:
print(-1)
elif a == 0 and b == 0:
print(0)
elif d < 0:
print(0)
else:
if a != 0:
res1 = (-b + sqrt(d))/(2*a)
res2 = (-b - sqrt(d))/(2*a)
if res1 == res2:
print(1)
print('%.10f' %(res1))
else:
if res1 < res2:
print(2)
print('%.10f' % (res1))
print('%.10f' % (res2))
else:
print(2)
print('%.10f' % (res2))
print('%.10f' % (res1))
else:
res1 = -c/b
print(1)
print('%.10f' %(res1))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
import math
A, B, C = map(int, input().split())
if A < 0:
A, B, C = -A, -B, -C
if A != 0:
some_num = B * B / (4 * A) - C
if A == 0:
if B == 0 and C == 0:
print(-1)
elif B != 0:
print(1)
print(-C / B)
else:
print(0)
elif some_num > 0:
print(2)
print((-math.sqrt(some_num) - B / (2 * math.sqrt(A))) / math.sqrt(A))
print((math.sqrt(some_num) - B / (2 * math.sqrt(A))) / math.sqrt(A))
elif -1e-8 < some_num < 1e-8:
print(1)
print(-B / (2 * A))
else:
print(0)
| 8 |
PYTHON3
|
a,b,c=list(map(float,input().split()))
if a==0 and b==0 and c==0: print(-1)
elif a==0 and b==0 and c!=0: print(0)
elif a==0:
print(1)
print(-c/b)
elif b*b-4*a*c<0: print(0)
else:
a1,a2=(-b+(b*b-a*4*c)**0.5)/(2*a),(-b-(b*b-a*4*c)**0.5)/(2*a)
if a1==a2:
print(1)
print('{0:.5f}'.format(a1))
else:
print(2)
print('{0:.6f}'.format(min(a1,a2)))
print('{0:.6f}'.format(max(a1,a2)))
| 8 |
PYTHON3
|
a,b,c=map(int,input().split())
if a==0:
if b==0:
if c==0:
print("-1")
else:
print("0")
else:
print(1)
print("%.6f"%((-c)/b))
else:
d=b*b-4*a*c
if d<0:
print(0)
elif d==0:
print(1)
print("%.6f"%((-b)/(2*a)))
else:
print(2)
l=[((-b-(d**0.5))/(2*a)),((-b+(d**0.5))/(2*a))]
l.sort()
print("%.6f"%l[0])
print("%.6f"%l[1])
| 8 |
PYTHON3
|
import math
data = [int(x) for x in input().split()]
a = data[0]
b = data[1]
c = data[2]
if a == 0 and b == 0 and c == 0:
print(-1)
elif a == 0 and b == 0:
print(0)
elif a == 0 and b != 0:
print(1)
print(-c/b)
elif (b ** 2) - (4 * a * c) < 0:
print(0)
else:
ans1 = (-b + math.sqrt((b ** 2) - (4 * a * c)))/(2*a)
ans2 = (-b - math.sqrt((b ** 2) - (4 * a * c)))/(2*a)
if ans1 == ans2:
print(1)
print(ans1)
else:
answers = [ans1,ans2]
answers.sort()
print(2)
print(answers[0])
print(answers[1])
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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);
}
}
}
| 8 |
CPP
|
import math
import time
import sys
import os
from math import gcd, floor, sqrt, log
start_time = time.time()
def iin(): return int(input())
def sin(): return input().strip()
def listin(): return list(map(int, input().strip().split()))
def liststr(): return list(map(str, input().strip().split()))
def ceill(x): return int(x) if(x == int(x)) else int(x)+1
def ceilldiv(x, d): x//d if(x % d == 0) else x//d+1
def LCM(a, b): return (a*b)//gcd(a, b)
def solve():
a, b, c = listin()
if a == 0:
if b == 0:
if c == 0:
print(-1)
return
print(0)
return
print(1)
print("{0:.10f}".format((-1*c)/b))
return
d = b**2 - (4*a*c)
if d < 0:
print(0)
return
x = set()
x.add(((-1*b)-sqrt(d))/(2*a))
x.add(((-1*b)+sqrt(d))/(2*a))
x = list(x)
x.sort()
print(len(x))
for i in x:
print("{0:.10f}".format(i))
t = 1
# t = int(input())
for hula in range(t):
solve()
sys.stderr.write(str(time.time()-start_time))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double a, b, c, x1, x2, d;
cin >> a >> b >> c;
if (a == 0) {
if (b != 0) {
x1 = -c / b;
cout << 1 << endl;
cout.precision(10);
cout << fixed << x1 << endl;
} else if (c == 0)
cout << -1 << endl;
else
cout << 0;
} else {
d = b * b - 4 * a * c;
if (d < 0)
cout << 0 << endl;
else if (d == 0) {
x1 = -b / (2 * a);
cout << 1 << endl;
cout.precision(10);
cout << fixed << x1 << endl;
} else {
x1 = (-b + sqrt(d)) / (2 * a);
x2 = (-b - sqrt(d)) / (2 * a);
cout << 2 << endl;
cout.precision(10);
cout << fixed << min(x1, x2) << endl;
cout << fixed << max(x1, x2) << endl;
}
}
return 0;
}
| 8 |
CPP
|
import math
a, b, c = map(float, input().split())
d = b * b - 4. * a * c
if d < 0:
print(0)
exit()
if a == 0 and b == 0 and c == 0:
print(-1)
exit()
if a == 0 and b == 0:
print(0)
exit()
if a == 0:
print(1)
print("{0:.6f}".format(-c / b))
exit()
x1 = (-b + math.sqrt(d)) / (2. * a)
x2 = (-b - math.sqrt(d)) / (2. * a)
if x1 == x2:
print(1)
print("{0:.6f}".format(x1))
exit()
print(2)
if x1 < x2:
print("{0:.6f}".format(x1))
print("{0:.6f}".format(x2))
else:
print("{0:.6f}".format(x2))
print("{0:.6f}".format(x1))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
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 (a == 0) {
printf("1\n");
printf("%.6lf\n", -1.0 * c / b);
} else if (b * b > 4 * a * c) {
printf("2\n");
double x1 = 1.0 * (-b + sqrt(1.0 * (b * b - 4 * a * c))) / (2 * a);
double x2 = 1.0 * (-b - sqrt(1.0 * (b * b - 4 * a * c))) / (2 * a);
printf("%.6lf\n%.6lf", min(x1, x2), max(x1, x2));
} else if (b * b == 4 * a * c) {
printf("1\n");
double x1 = 1.0 * (-b) / (2 * a);
printf("%.6lf", x1);
} else
printf("0\n");
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
scanf("%I64d%I64d%I64d", &a, &b, &c);
if (a == 0) {
if (b == 0)
printf("%d", (c == 0 ? -1 : 0));
else
printf("1\n%.10f", -1.0 * c / b);
} else {
double res[2];
long long det = b * b - 4 * a * c;
if (det < 0)
printf("0");
else if (det == 0)
printf("1\n%.10f", -0.5 * b / a);
else {
res[0] = (-b + sqrt(det)) / (2 * a);
res[1] = (-b - sqrt(det)) / (2 * a);
sort(res, res + 2);
printf("2\n%.10f\n%.10f", res[0], res[1]);
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int dx[9] = {0, 1, -1, 0, 0, -1, -1, 1, 1};
const int dy[9] = {0, 0, 0, -1, 1, -1, 1, -1, 1};
const double pi = acos(-1.0);
const int N = 1e6 + 100;
const int MOD = 1e9 + 7;
long long a, b, c;
double temp;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> a >> b >> c;
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 << endl;
double ans = (-1.0) * c / b;
cout << fixed << setprecision(10) << ans << endl;
return 0;
}
temp = b * b - 4 * a * c;
if (temp < 0) {
cout << 0 << endl;
} else if (temp == 0) {
cout << 1 << endl;
double ans = -1.0 * b / (2 * a);
cout << fixed << setprecision(10) << ans << endl;
} else if (temp > 0) {
cout << 2 << endl;
temp = sqrt(temp);
double ans1 = (-1.0 * b - temp) / (1.0 * 2 * a),
ans2 = (-1.0 * b + temp) / (1.0 * 2 * a);
if (ans1 > ans2) swap(ans1, ans2);
cout << fixed << setprecision(10) << ans1 << endl << ans2 << endl;
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
struct node {
double x1, x2;
int n;
} cx;
node solve() {
node ax;
if (a == 0 && b == 0 && c == 0) {
ax.n = -1;
return ax;
}
if (a == 0 && b == 0 && c != 0) {
ax.n = 0;
return ax;
}
if (a == 0 && b != 0 && c != 0) {
ax.n = 1;
ax.x1 = -c / b;
return ax;
}
if (a == 0 && b != 0 && c == 0) {
ax.n = 1;
ax.x1 = 0.0;
return ax;
}
double y = b * b - 4 * a * c;
if (y < 0) {
ax.n = 0;
return ax;
}
if (y == 0) {
ax.n = 1;
ax.x1 = -b / (2 * a);
return ax;
}
ax.n = 2;
ax.x1 = (-b + sqrt(y)) / (2 * a);
ax.x2 = (-b - sqrt(y)) / (2 * a);
return ax;
}
int main() {
while (scanf("%lf %lf %lf", &a, &b, &c) != EOF) {
cx = solve();
if (cx.n == 0 || cx.n == -1) {
printf("%d\n", cx.n);
}
if (cx.n == 1) {
printf("%d\n%.10lf\n", cx.n, cx.x1);
continue;
}
if (cx.n == 2) {
if (cx.x1 < cx.x2) swap(cx.x1, cx.x2);
printf("%d\n%.10lf\n%.10lf\n", cx.n, cx.x2, cx.x1);
}
}
}
| 8 |
CPP
|
#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;
if (a == 0 && b == 0 && c != 0) cout << 0;
if (a != 0 && b != 0) {
long long int d = b * b - 4 * a * c;
if (d < 0) cout << 0;
if (d > 0) {
cout << 2 << "\n";
int p = -b - sqrt(d);
int q = -b + sqrt(d);
if (a > 0) {
cout << fixed << setprecision(5) << (-b - sqrt(d)) / (2 * a) << "\n";
cout << fixed << setprecision(5) << (-b + sqrt(d)) / (2 * a);
} else {
cout << fixed << setprecision(5) << (-b + sqrt(d)) / (2 * a) << "\n";
cout << fixed << setprecision(5) << (-b - sqrt(d)) / (2 * a);
}
}
if (d == 0) {
cout << 1 << "\n";
cout << fixed << setprecision(5) << -b / (2 * a);
}
}
if (a == 0 && b != 0) {
cout << 1 << "\n";
cout << fixed << setprecision(5) << -c / b;
}
if (a != 0 && b == 0) {
if (c > 0) cout << 0;
if (c == 0)
cout << 1 << "\n"
<< "0.000000000";
if (c < 0) {
cout << 2 << "\n";
cout << fixed << setprecision(5) << -sqrt(c / a) << "\n" << sqrt(c / a);
}
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
a = double(a);
b = double(b);
c = double(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 << double(-c / b);
} else if (d == 0) {
cout << 1 << "\n";
cout << fixed << double((-b + double(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";
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long iA, iB, iC, iDelta;
double iX1, iX2;
cin >> iA >> iB >> iC;
if (iA == 0) {
if (iB == 0 && iC == 0) {
cout << -1;
goto endapp;
} else if (iB == 0 && iC != 0) {
cout << 0;
goto endapp;
} else {
iX1 = double(-iC) / double(iB);
cout.setf(ios::fixed);
cout << 1 << setprecision(10) << endl << iX1;
goto endapp;
}
}
iDelta = iB * iB - 4 * iA * iC;
if (iDelta < 0) {
cout << 0;
goto endapp;
}
iX1 = (double(-iB) - sqrt(iDelta)) / (2 * double(iA));
iX2 = (double(-iB) + sqrt(iDelta)) / (2 * double(iA));
if (iX1 > iX2) {
swap(iX1, iX2);
}
if (iDelta != 0) {
cout.setf(ios::fixed);
cout << 2 << '\n' << setprecision(10) << iX1 << '\n' << iX2;
} else {
cout.setf(ios::fixed);
cout << 1 << '\n' << setprecision(10) << iX1;
}
endapp:
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
signed long long tonum(string s) {
stringstream in(s);
signed long long x;
in >> x;
return x;
}
string tostr(signed long long n) {
stringstream in;
in << n;
string x;
in >> x;
return x;
}
signed long long gcd(signed long long a, signed long long b) {
while (1) {
a = a % b;
if (a == 0) return b;
b = b % a;
if (b == 0) return a;
}
}
int main() {
signed 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("%.9lf\n", double(0 - C) / double(B));
}
} else if (B == 0) {
if (C * A > 0)
printf("0\n");
else if (C == 0) {
printf("1\n");
printf("%.9lf\n", 0.0);
} else {
printf("2\n");
printf("%.9lf\n", sqrt((0.0 - double(C)) / double(A)) * -1);
printf("%.9lf\n", sqrt((0.0 - double(C)) / double(A)));
}
} else {
signed long long D = B * B - 4 * A * C;
if (D < 0)
printf("0\n");
else if (D == 0) {
printf("1\n");
printf("%.9lf\n", double(0.0 - double(B)) / (2.0 * double(A)));
} else {
printf("2\n");
if (A >= 0) {
printf("%.9lf\n",
(double(0.0 - double(B)) - sqrt(double(D))) / (2.0 * double(A)));
printf("%.9lf\n",
(double(0.0 - double(B)) + sqrt(double(D))) / (2.0 * double(A)));
} else {
printf("%.9lf\n",
(double(0.0 - double(B)) + sqrt(double(D))) / (2.0 * double(A)));
printf("%.9lf\n",
(double(0.0 - double(B)) - sqrt(double(D))) / (2.0 * double(A)));
}
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
double p, q;
while (cin >> a >> b >> c) {
if (a == 0 && b == 0 && c == 0)
cout << -1 << endl;
else if (a == 0 && b == 0 && c != 0)
cout << 0 << endl;
else if (a == 0) {
if (b != 0 && c == 0) {
cout << 1 << endl;
p = 0 * 1.0;
printf("%lf\n", p);
} else {
cout << 1 << endl;
p = 1.0 * (-c / b);
printf("%lf", p);
}
} else {
if (b * b - 4 * a * c == 0) {
cout << 1 << endl;
p = -b / (2 * a) * 1.0;
if (!p) p = 0;
printf("%lf\n", p);
} else if (b * b - 4 * a * c > 0) {
cout << 2 << endl;
p = (-b - sqrt(b * b - 4 * a * c)) / (2 * a) * 1.0;
q = (-b + sqrt(b * b - 4 * a * c)) / (2 * a) * 1.0;
if (p > q) swap(p, q);
printf("%lf\n%lf\n", p, q);
} else
cout << 0;
}
}
return 0;
}
| 8 |
CPP
|
import sys
import math
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
if __name__ == '__main__':
q = inlt()
a = q[0]
b = q[1]
c = q[2]
if a == 0 :
if b == 0 and c == 0 :
print("-1")
else :
if b == 0 :
print("0")
else :
print("1")
print("{:.6f}".format(-1*c / b))
else :
d = b*b - 4*a*c
if d > 0 :
print("2")
bb = [ (-1*b + math.sqrt(d))/(2*a) ,(-1*b - math.sqrt(d))/(2*a) ]
bb.sort()
print("{:.6f}".format(bb[0]))
print("{:.6f}".format(bb[1]))
else :
if d == 0 :
print("1")
print("{:.6f}".format(-b/(2*a)))
else :
print("0")
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long A, B, C;
cin >> A >> B >> C;
if (!A) {
if (!B) {
if (!C)
cout << -1;
else
cout << 0;
return 0;
}
cout << 1 << '\n';
cout << fixed << setprecision(10) << (long double)-C / B;
return 0;
}
long long D = B * B - 4 * A * C;
if (D < 0) {
cout << 0;
return 0;
}
if (!D) {
cout << 1 << '\n';
cout << fixed << setprecision(10) << (long double)-B / (2 * A);
return 0;
}
cout << 2 << '\n';
if (A < 0) {
cout << fixed << setprecision(10) << (long double)(-B + sqrt(D)) / (2 * A)
<< '\n';
cout << fixed << setprecision(10) << (long double)(-B - sqrt(D)) / (2 * A);
} else {
cout << fixed << setprecision(10) << (long double)(-B - sqrt(D)) / (2 * A)
<< '\n';
cout << fixed << setprecision(10) << (long double)(-B + sqrt(D)) / (2 * A);
}
return 0;
}
| 8 |
CPP
|
a,b,c = map(int, input().split())
D = int(b*b - 4*a*c)
if a == 0 and b ==0 and c == 0:
print(-1)
else:
if D > 0 and a != 0:
print(2)
if -(b+D**0.5)/(2*a) < -(b-D*00.5)/(2*a):
print(-(b+D**0.5)/(2*a))
print(-(b-D**0.5)/(2*a))
else:
print(-(b-D**0.5)/(2*a))
print(-(b+D**0.5)/(2*a))
elif D == 0 and a != 0:
print(1)
print(int(-b/(2*a)))
elif a == 0 and b != 0:
print(1, -c/b , sep='\n')
else:
print(0)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d, x1, x2;
cin >> a >> b >> c;
d = (b * b) - 4 * a * c;
if (a == 0 && b == 0 && c == 0)
cout << "-1\n";
else if (a == 0 && b == 0)
cout << "0\n";
else if (d < 0)
cout << "0\n";
else if (a == 0) {
cout << "1\n";
printf("%0.7lf\n", -c / b);
} else if (d == 0) {
cout << "1\n";
printf("%0.7lf\n", -b / (2 * a));
} else {
d = sqrt(d);
x1 = (-b - d) / (2 * a);
x2 = (-b + d) / (2 * a);
cout << "2\n";
printf("%0.7lf\n%0.7lf\n", min(x1, x2), max(x1, x2));
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d, x1, x2;
cin >> a >> b >> c;
if ((a == 0) && (b == 0) && (c == 0)) {
cout << -1;
goto l;
}
if ((a == 0) && (b == 0)) {
cout << 0;
goto l;
}
if (a == 0) {
cout << "1\n";
printf("%.6f", -c / b);
goto l;
}
if (b * b - 4 * a * c < 0) {
cout << 0;
goto l;
}
d = sqrt(b * b - 4 * a * c);
x1 = (-b - d) / (2 * a);
x2 = (-b + d) / (2 * a);
if (d == 0) {
cout << "1\n";
printf("%.6f", x1);
goto l;
}
cout << "2\n";
printf("%.6f", min(x1, x2));
printf("\n%.6f", max(x2, x1));
l:;
}
| 8 |
CPP
|
# http://codeforces.com/problemset/problem/20/B
from math import sqrt
a, b, c, = [int(x) for x in input().split(' ')]
def number_solutions(a, b, c):
d = b**2 - 4*a*c
if a == 0 and b == 0 and c != 0:
return 0
elif a == 0 and b == 0 and c == 0:
return -1
elif a == 0 and b != 0:
return 1
elif d > 0:
return 2
elif d == 0:
return 1
else:
return 0
def quadratic(a, b, c):
ans = []
if a == 0:
ans.append(-c/b)
else:
ans.append((-b + sqrt(b**2 - 4*a*c)) / (2*a))
ans.append((-b - sqrt(b**2 - 4*a*c)) / (2*a))
return ans
if number_solutions(a, b, c) == -1:
print(-1)
elif number_solutions(a, b, c) == 2:
print(2)
for q in sorted(quadratic(a, b, c)):
print('{:.5f}'.format(q))
elif number_solutions(a, b, c) == 1:
print(1)
print('{:.5f}'.format(quadratic(a, b, c)[0]))
else:
print(0)
| 8 |
PYTHON3
|
#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;
return 0;
}
if (a == 0 && b == 0) {
cout << 0;
return 0;
}
if (a == 0) {
cout << 1 << endl << fixed << setprecision(5) << (-1 * c / b);
return 0;
}
if (d < 0) {
cout << 0;
return 0;
}
if (d == 0) {
cout << 1 << endl << fixed << setprecision(5) << -1 * (b / (2 * a));
return 0;
}
double e = (-b - (sqrt(d))) / (2 * a), f = (-b + (sqrt(d))) / (2 * a);
cout << 2 << endl
<< fixed << setprecision(9) << min(e, f) << endl
<< fixed << setprecision(9) << max(e, f);
}
| 8 |
CPP
|
#include <bits/stdc++.h>
const double eps = 1e-6;
int main() {
double a, b, c;
while (std::cin >> a >> b >> c) {
if (fabs(a) < eps) {
if (fabs(b) < eps) {
if (fabs(c) > eps) {
puts("0");
} else {
puts("-1");
}
} else {
double ans = -c / b;
puts("1");
printf("%.6lf\n", ans);
}
} else {
double delta = b * b - 4 * a * c;
if (delta < 0) {
puts("0");
} else if (fabs(delta) == 0) {
double ans = -b / (2 * a);
puts("1");
printf("%.6lf\n", ans);
} else {
double ans1 = (-b - sqrt(delta)) / (2 * a);
double ans2 = (-b + sqrt(delta)) / (2 * a);
if (ans1 > ans2) {
std::swap(ans1, ans2);
}
puts("2");
printf("%.6lf %.6lf\n", ans1, ans2);
}
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a;
double b;
double c;
cin >> a;
cin >> b;
cin >> c;
double D = (b * b) - (4 * a * c);
double x = (sqrt(D) - b) / (2 * a);
double y = (-(sqrt(D)) - b) / (2 * a);
double z = ((-1) * c) / b;
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
} else if (a == 0 && b != 0) {
cout << "1" << endl;
printf("%.10f\n", z);
} else if (D < 0 || (a == 0 && b == 0)) {
cout << "0" << endl;
} else if (D == 0) {
cout << "1" << endl;
printf("%.10f\n", x);
} else {
cout << "2" << endl;
if (x > y) {
printf("%.10f\n", y);
printf("%.10f\n", x);
} else {
printf("%.10f\n", x);
printf("%.10f\n", y);
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cout << fixed << setprecision(9);
long long a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
cout << (c == 0 ? -1 : 0) << '\n';
return 0;
}
cout << "1\n";
cout << (double)(-c) / b << '\n';
return 0;
}
long long d = b * b - 4LL * a * c;
if (d < 0) {
cout << "0\n";
return 0;
}
if (d == 0) {
cout << "1\n";
cout << (double)(-b) / (2.0 * a) << '\n';
return 0;
}
cout << "2\n";
vector<double> sols;
sols.push_back((double)(-b - sqrtl(d)) / (2.0 * a));
sols.push_back((double)(-b + sqrtl(d)) / (2.0 * a));
sort(sols.begin(), sols.end());
cout << sols[0] << '\n' << sols[1] << '\n';
}
| 8 |
CPP
|
#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 << double((-b + double(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";
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d, r1, r2;
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" << endl;
r1 = -c / b;
printf("%5f", r1);
} else {
d = b * b - 4 * a * c;
if (d < 0)
cout << "0";
else if (d == 0) {
cout << "1" << endl;
r1 = -b / (2 * a);
printf("%5f", r1);
} else {
r1 = (-b + sqrt(d)) / (2 * a);
r2 = (-b - sqrt(d)) / (2 * a);
cout << "2" << endl;
if (r1 < r2)
printf("%5f %5f", r1, r2);
else
printf("%5f %5f", r2, r1);
}
}
return 0;
}
| 8 |
CPP
|
#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;
scanf("%lf%lf%lf", &a, &b, &c);
double t = b * b - 4 * a * c;
if (t < -1e-9) {
puts("0");
return 0;
} else if (t < 1e-9) {
if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
return 0;
} else if (a == 0 && b == 0 && (c != 0)) {
puts("0");
return 0;
} else {
puts("1");
printf("%.10lf\n", -b / (2 * a));
return 0;
}
}
double s = sqrt(b * b - 4 * a * c);
if (a == 0) {
puts("1");
printf("%.10lf\n", -c / b);
return 0;
}
puts("2");
double aa = (-b - s) / (2 * a);
double bb = (-b + s) / (2 * a);
printf("%.10lf\n%.10lf\n", min(aa, bb), (max(aa, bb)));
}
| 8 |
CPP
|
from math import sqrt
def equation(a, b, c):
if a != 0:
d = b ** 2 - 4 * a * c
if d > 0 and a > 0:
x1 = (-b - sqrt(d)) / (2 * a)
x2 = (-b + sqrt(d)) / (2 * a)
return 2, x1, x2
elif d > 0 and a < 0:
x1 = (-b + sqrt(d)) / (2 * a)
x2 = (-b - sqrt(d)) / (2 * a)
return 2, x1, x2
elif d == 0:
x = -b / (2 * a)
return 1, x
else:
return [0]
else:
if b == c == 0:
return [-1]
elif b != 0:
x = - c / b
return 1, x
else:
return [0]
A, B, C = [int(i) for i in input().split()]
print(*equation(A, B, C), sep='\n')
| 8 |
PYTHON3
|
import math
A,B,C = map(int,input().split())
D=B*B-4*A*C
if A==0 and B==0 and C==0:
print(-1)
elif A==0 and B==0:
print(0)
elif A==0:
x=-C/B
print(1)
print('%5.5f'%x)
elif D<0:
print(0)
elif D>0:
print(2)
x1=(-B+math.sqrt(D))/(2*A)
x2=(-B-math.sqrt(D))/(2*A)
if x1 < x2:
print("%5.5f" % x1)
print("%5.5f" % x2)
else:
print("%5.5f" % x2)
print("%5.5f" % x1)
"""vyvodx1='%5.5f'%x1
vyvodx2='%5.5f'%x2"""
"""print(vyvodx1)
print(vyvodx2)"""
elif D==0:
x=-B/(2*A)
print(1)
print('%5.5f'%x)
| 8 |
PYTHON3
|
import math
def solve_const(x):
if(x == 0):
print(-1)
else:
print(0)
def solve_lineal(x, y):
if(y == 0):
#yt = 0 => t = 0
print(1)
print(0)
else:
#xt + y = 0 => t = -y/x
print(1)
print(-y / x)
def solve_square(x, y, z):
d = y * y - 4 * x * z
if(d < 0):
print(0)
elif(d > 0):
print(2)
x1 = (-y + math.sqrt(d)) / (2 * x)
x2 = (-y - math.sqrt(d)) / (2 * x)
print(min(x1, x2))
print(max(x1, x2))
else:
print(1)
print((-y) / (2 * x))
a, b, c = map(int, input().split())
if(a == 0):
if(b == 0):
solve_const(c)
else:
solve_lineal(b, c)
else:
solve_square(a, b, c)
| 8 |
PYTHON3
|
a, b, c = map(int, input().split())
if a == 0 and b == 0:
print('0' if c else '-1')
elif a == 0:
print('1', -c / b, sep='\n')
else:
d, x = b ** 2 - 4 * a * c, 2 * a
if d < 0:
print('0')
elif d == 0:
print('1', -b / x, sep='\n')
else:
r = sorted(((-b + d ** 0.5) / x, (-b - d ** 0.5) / x))
print('2', r[0], r[1], sep='\n')
| 8 |
PYTHON3
|
a,b,c = [int(x) for x in input().split()]
if a == 0 and b == 0 and c == 0:
print(-1)
elif a == 0:
if b == 0:
print(0)
else:
print(1)
print(-c/b)
else:
disc = b**2 - 4*a*c
denom = 2*a
if disc == 0:
print(1)
print(-b/denom)
elif disc < 0:
print(0)
else:
print(2)
if a > 0:
print((-b-disc**0.5)/denom)
print((-b+disc**0.5)/denom)
else:
print((-b+disc**0.5)/denom)
print((-b-disc**0.5)/denom)
| 8 |
PYTHON3
|
a, b, c = map(int, input().split())
if a < 0:
a = -a
b = -b
c = -c
x = (b**2)-(4*a*c)
if a == 0:
if b == 0:
if c == 0:
print(-1)
else:
print(0)
else:
print(1)
print(f'{-c*1.0/b:.7f}')
elif x == 0:
print(1)
print(f'{-b/(2*a):.7f}')
elif x > 0:
from math import sqrt
x = sqrt(x)
a1 = (-b-x)/(2*a)
a2 = (-b+x)/(2*a)
print(2)
print(f'{a1:.7f}')
print(f'{a2:.7f}')
else:
print(0)
| 8 |
PYTHON3
|
import math
A, B, C = [int(i) for i in input().split()]
X = B * B - 4 * A * C
if A == 0 and B == 0 and C == 0:
print(-1)
elif A == 0 and B == 0:
print(0)
elif A == 0:
print(1)
print('{0:.10f}'.format(-C / B, 6))
elif X < 0:
print(0)
elif X == 0:
print(1)
print('{0:.10f}'.format(-B / (2 * A)))
else:
print(2)
ans = sorted([-(B + math.sqrt(X)) / (2 * A), -(B - math.sqrt(X)) / (2 * A)])
print('{0:.10f}'.format(ans[0]))
print('{0:.10f}'.format(ans[1]))
| 8 |
PYTHON3
|
R=lambda: map(int,input().split())
a,b,c=R()
if a==0 and b==0 and c==0:
print("-1")
elif (b**2)<4*a*c:
print("0")
elif a==0:
if b==0:
print("0")
else:
print("1")
print("{0:.5f}".format(-(c/b)))
else:
d= (b**2)-4*a*c
r1= (-b+pow(d,0.5))/(2*a)
r2= (-b-pow(d,0.5))/(2*a)
if r1==r2:
print("1")
print("{0:.5f}".format(min(r1,r2)))
else:
print("2")
print("{0:.5f}".format(min(r1,r2)))
print("{0:.5f}".format(max(r1,r2)))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, line;
double A, B, C, x1, x2, mid;
cin >> A >> B >> C;
mid = (B * B) - (4 * A * C);
if (A == 0 && B == 0 && C == 0) {
printf("-1\n");
} else if (A == 0 && B == 0)
printf("0\n");
else if (mid < 0.0)
printf("0\n");
else if (A == 0) {
x1 = -C / B;
printf("1\n%lf\n", x1);
} else {
mid = sqrt(mid);
x1 = -B + mid;
x1 = (x1 / (2.0 * A));
x2 = -B - mid;
x2 = (x2 / (2.0 * A));
if (x1 == x2)
printf("1\n%lf\n", x1);
else if (x1 < x2)
printf("2\n%lf\n%lf\n", x1, x2);
else
printf("2\n%lf\n%lf\n", x2, x1);
}
return 0;
}
| 8 |
CPP
|
a, b, c = map(int,input().split())
if a != 0:
if b**2-4*a*c >= 0:
root1 = (-b + (b**2-4*a*c)**0.5)/(2*a)
root2 = (-b - (b**2-4*a*c)**0.5)/(2*a)
list = [root1, root2]
if root1 == root2:
print(1)
print(root1)
else:
print(2)
print(min(list))
print(max(list))
else:
print(0)
if a == 0 and b !=0:
print(1)
print(-c/b)
if a == 0 and b == 0:
if c == 0:
print(-1)
elif c != 0:
print(0)
| 8 |
PYTHON3
|
x,y,z=[int(i) for i in input().split()]
a=y**2-4*x*z
if x==0 and y==0 and z==0:
print(-1)
elif x==0 and y==0:
print(0)
elif x==0:
print(1)
print(-z/y)
elif a<0:
print(0)
elif a==0:
print(1)
print(-y/(2*x))
else:
print(2)
y=y/x
a=a/(x**2)
print((-y-a**0.5)/2)
print((-y+a**0.5)/2)
| 8 |
PYTHON3
|
import math
a,b,c=map(int,input().split())
if a==0:
if b==0 and c!=0:
print(0)
elif b==0 and c==0:
print(-1)
else:
x=-c/b
print(1)
print("%.10f" %x)
else:
d=b*b-4*a*c
if d<0:
print(0)
else:
if d>0:
ans=[]
ans.append((-b+math.sqrt(d))/(2*a))
ans.append((-b-math.sqrt(d))/(2*a))
print(2)
ans.sort()
print("%.10f" %ans[0])
print("%.10f" %ans[1])
else:
y=((-b-math.sqrt(d))/(2*a))
print(1)
print("%.10f" %y)
| 8 |
PYTHON3
|
import math
a,b,c = list(map(int, input().split(" ")))
if a == 0 and b == 0 and c == 0:
print(-1)
elif a == 0 and b != 0:
print(1)
print('{0:.5f}'.format(-c/b))
elif a == 0 and b == 0 and c != 0:
print(0)
else:
d = b**2 - 4 * a * c
if d > 0:
x1 = (-b + math.sqrt(d))/(2*a)
x2 = (-b - math.sqrt(d))/(2*a)
if x1 > x2:
x1,x2 = x2,x1
print(2)
print('{0:.5f}'.format(x1))
print('{0:.5f}'.format(x2))
elif d == 0:
x = -b/(2*a)
print(1)
print('{0:.5f}'.format(x))
else:
print(0)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long a, b, c, d;
long double k, x1, x2;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0)
c == 0 ? cout << -1 : cout << 0;
else
cout << "1\n" << fixed << setprecision(10) << (double)(-c) / b;
} else {
d = b * b - 4 * a * c;
if (d > 0) {
k = sqrt(d);
x1 = (double)(-b - k) / (2 * a);
x2 = (double)(k - b) / (2 * a);
cout << "2\n"
<< fixed << setprecision(10) << min(x1, x2) << "\n"
<< max(x1, x2);
} else
d < 0 ? cout << 0
: cout << "1\n"
<< fixed << setprecision(10) << (double)(-b) / (2 * a);
}
return 0;
}
| 8 |
CPP
|
import math
A, B, C = input().split()
A, B, C = float(A), float(B), float(C)
if A == 0 and B == 0:
if C == 0:
print(-1)
else:
print(0)
elif A == 0:
print(1)
print("%.10f" % (-C / B))
else:
det = B * B - 4 * A * C
if det < 0:
print(0)
elif det == 0:
print(1)
x = -B / (2 * A)
print("%.10f" % x)
else:
print(2)
x1 = (-B + math.sqrt(det)) / (2 * A)
x2 = (-B - math.sqrt(det)) / (2 * A)
if x1 < x2:
print("%.10f" % x1)
print("%.10f" % x2)
else:
print("%.10f" % x2)
print("%.10f" % x1)
| 8 |
PYTHON3
|
from math import sqrt
a,b,c=map(int,input().split())
if a==b==c==0:
print(-1)
elif a==b==0:
print(0)
elif a==0:
print(1)
print(-c/b)
else:
if b**2==(4*a*c):
print(1)
print((-b)/(2*a))
elif (4*a*c)>b**2:
print(0)
else:
print(2)
x=((-b+sqrt(b**2-(4*a*c)))/(2*a))
y=(-b - sqrt(b ** 2 - (4 * a * c))) / (2 * a)
print('{0:.16f}'.format(min(x,y)))
print('{0:.16f}'.format(max(x,y)))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, x, y, r1, r2, m, n;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
printf("-1");
else
printf("0");
} else {
x = -1 * (c / b);
printf("1\n%.5lf", x);
}
} else {
y = b * b - 4 * a * c;
if (y < 0) printf("0"), exit(0);
r1 = (-b + sqrt(y)) / 2 / a, r2 = (-b - sqrt(y)) / 2 / a;
if (r1 == r2) {
printf("1\n%.5lf", r1);
} else {
m = min(r1, r2);
n = max(r1, r2);
printf("2\n%.5lf\n%.5lf", m, n);
}
}
return 0;
}
| 8 |
CPP
|
import math
a, b, c=input().split()
a=int(a)
b=int(b)
c=int(c)
if ((a!=0 and b*b<4*a*c) or (a==b==0 and c!=0)): print ('0')
elif (a==b==c==0): print('-1')
elif (a==0):
print('1')
a1=-c/b
print (format(a1, '.5f'))
else:
a1=(-b-(b*b-4*a*c)**.5)/(2*a)
a2=(-b+(b*b-4*a*c)**.5)/(2*a)
if a1<a2: a1,a2=a2,a1
if (a1!=a2):
print('2')
print (format(a2, '.5f'))
print (format(a1, '.5f'))
else:
print('1')
print (format(a1, '.5f'))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long a, b, c;
cin >> a >> b >> c;
if (!a && !b && !c) {
cout << -1;
return 0;
}
if (!a && !b && c) {
cout << 0;
return 0;
}
if (!a) {
cout << 1 << '\n';
cout << setprecision(12) << ((double)(-c) / b);
return 0;
}
if (b * b - 4 * a * c < 0) {
cout << 0;
return 0;
}
if (b * b == 4 * a * c) {
cout << 1 << '\n';
cout << setprecision(12) << (double)(-b) / (2 * a);
return 0;
}
cout << 2 << '\n';
double r1 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a),
r2 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
if (r1 > r2) swap(r1, r2);
cout << setprecision(12) << r1 << '\n';
cout << setprecision(12) << r2 << '\n';
return 0;
}
| 8 |
CPP
|
__author__ = 'linh'
import math
def main():
n = input().split()
A = int(n[0])
B = int(n[1])
C = int(n[2])
if A==B==C==0:
print(-1)
elif A==B==0:
print(0)
elif A==0:
print(1)
print("{0:.5f}".format(-C/B))
else:
delta = B**2 -4*A*C
if delta <0:
print(0)
elif delta ==0:
print(1)
print("{0:.5f}".format(-B/(2*A)))
else:
print(2)
x1 = (-B-math.sqrt(delta))/(2*A)
x2 = (-B+math.sqrt(delta))/(2*A)
if x1<x2:
print("{0:.20f}".format(x1))
print("{0:.20f}".format(x2))
else:
print("{0:.20f}".format(x2))
print("{0:.20f}".format(x1))
if __name__ == '__main__':
main()
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, numberOfRoots, temp;
double r1, r2;
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 (a == 0) {
r1 = double(-c) / b;
cout << 1 << endl << fixed << setprecision(5) << r1 << endl;
return 0;
}
temp = b * b - 4 * a * c;
if (temp == 0)
numberOfRoots = 1;
else if (temp > 0)
numberOfRoots = 2;
else if (temp < 0) {
cout << 0 << endl;
return 0;
}
r1 = (-b + sqrt(temp)) / (2 * a);
r2 = (-b - sqrt(temp)) / (2 * a);
if (r1 > r2)
cout << numberOfRoots << endl
<< fixed << setprecision(5) << r2 << endl
<< fixed << setprecision(5) << r1 << endl;
else if (r1 < r2)
cout << numberOfRoots << endl
<< fixed << setprecision(5) << r1 << endl
<< fixed << setprecision(5) << r2 << endl;
else
cout << numberOfRoots << endl << fixed << setprecision(5) << r2 << endl;
return 0;
}
| 8 |
CPP
|
#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) {
if (b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else
cout << 1 << endl << fixed << setprecision(10) << (double)-c / b << endl;
} else {
if (d == 0) {
cout << 1 << endl;
cout << fixed << setprecision(10) << (double)(-b / (2 * a)) << endl;
} else {
if (d < 0)
cout << 0 << endl;
else {
cout << 2 << endl;
d = sqrt(d);
double x = (-b - d) / (2 * a);
double xx[2];
xx[0] = x;
xx[1] = (double)(-b + d) / (2 * a);
sort(xx, xx + 2);
cout << fixed << setprecision(10) << xx[0] << endl;
cout << fixed << setprecision(10) << xx[1] << endl;
}
}
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, d;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
} else {
if (a == 0) {
if (b != 0) {
cout << "1" << endl;
cout << fixed << setprecision(5) << (0 - c) / (1.0 * b) << endl;
} else
cout << "0" << endl;
} else {
d = b * b - 4 * a * c;
if (d > 0) {
double x1, x2;
cout << "2" << endl;
x1 = (0 - b + sqrt(d)) / (2.0 * a);
x2 = (0 - b - sqrt(d)) / (2.0 * a);
if (x1 > x2) swap(x1, x2);
cout << fixed << setprecision(5) << x1 << endl;
cout << fixed << setprecision(5) << x2 << endl;
} else if (d == 0) {
cout << "1" << endl;
cout << fixed << setprecision(5) << (0 - b) / (2.0 * a) << endl;
} else
cout << "0" << endl;
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d, e, f, g;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << "-1";
return 0;
}
if (a == 0 && b == 0) {
cout << "0" << endl;
return 0;
}
if (a == 0) {
cout << "1" << endl;
cout << std ::fixed;
cout << setprecision(7) << (-c) / b << endl;
return 0;
}
d = (b * b) - (4 * a * c);
e = (-b + sqrt(d)) / (2 * a);
f = (-b - sqrt(d)) / (2 * a);
g = (-b) / (2 * a);
if (d == 0) {
cout << "1" << endl;
cout << std ::fixed;
cout << setprecision(7) << g << endl;
}
if (d < 0) {
cout << 0 << endl;
}
if (d > 0) {
cout << "2" << endl;
if (e > f) {
cout << std ::fixed;
cout << setprecision(7) << f << endl;
cout << std ::fixed;
cout << setprecision(7) << e << endl;
} else if (e < f) {
cout << std ::fixed;
cout << setprecision(7) << e << endl;
cout << std ::fixed;
cout << setprecision(7) << f << endl;
}
}
}
| 8 |
CPP
|
import math
a, b, c = map(int, input().split())
delta = (b*b) - (4*a*c)
# print(delta)
if delta < 0:
print("0")
# elif a+b+c == 0:
# print("-1")
else:
if a != 0:
x1 = (-b + math.sqrt(delta))/(a*2)
x2 = (-b - math.sqrt(delta))/(a*2)
if delta == 0:
print("1")
print("%.5f" % x1)
else:
print("2")
if x1 > x2:
x1, x2 = x2, x1
print("%.5f" % x1)
print("%.5f" % x2)
elif b != 0:
x = -c/b
print("1")
print("%.5f" % x)
elif c!=0:
print("0")
else:
print("-1")
| 8 |
PYTHON3
|
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
from math import sqrt
def main():
a,b,c = map(int,input().split())
if a == b == c == 0:
print(-1)
elif a == b == 0:
print(0)
elif a == 0:
print(1)
print('%.10f'%(-c/b))
else:
d2 = b*b-4*a*c
if d2 < 0:
print(0)
elif d2 == 0:
print(1)
print('%.10f'%(-b/(2*a)))
else:
d = sqrt(d2)
print(2)
if a > 0:
print('%.10f'%((-b-d)/(2*a)))
print('%.10f'%((-b+d)/(2*a)))
else:
print('%.10f'%((-b+d)/(2*a)))
print('%.10f'%((-b-d)/(2*a)))
# Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main()
| 8 |
PYTHON3
|
from math import *
a=[int(i) for i in input().split()]
if(a[0]==0 and a[1]==0 and a[2]==0):
print("-1")
exit()
if(a[0]==0 and a[1]!=0):
print("1")
print((-a[2])/a[1])
elif(a[0]==0 and a[1]==0):
print("0")
exit()
else:
if((a[1]*a[1]-4*a[0]*a[2])<0):
print("0")
elif((a[1]*a[1]-4*a[0]*a[2])==0):
print("1")
print((-a[1])/(2*a[0]))
else:
print(2)
print(min((-a[1]+sqrt(a[1]*a[1]-4*a[0]*a[2]))/ (2*a[0]),(-a[1]-sqrt(a[1]*a[1]-4*a[0]*a[2]))/(2*a[0])))
print(max((-a[1]+sqrt(a[1]*a[1]-4*a[0]*a[2]))/(2*a[0]),(-a[1]-sqrt(a[1]*a[1]-4*a[0]*a[2]))/(2*a[0])))
| 8 |
PYTHON3
|
import math
a,b,c=map(int,input().split())
if a:
if b*b-4*a*c>0:
print(2)
print(min((-b-math.sqrt(b*b-4*a*c))/2/a,(-b+math.sqrt(b*b-4*a*c))/2/a))
print(max((-b-math.sqrt(b*b-4*a*c))/2/a,(-b+math.sqrt(b*b-4*a*c))/2/a))
elif b*b-4*a*c==0:
print(1)
print(round(-b/2/a,5))
else:
print(0)
elif b:
print(1)
print(-c/b)
else:
print(0 if c else -1)
| 8 |
PYTHON3
|
import math
def solver(a, b, c):
d = b**2-4*a*c
if a == 0 and b!=0:
print('1')
print('%.5f'%(-c/b))
elif a == 0 and b == 0 and c == 0:
print(-1)
elif a == 0 and b == 0 and c!=0:
print('0')
elif d < 0:
print(0)
elif d == 0 and (a!= 0):
x1 = (-b + math.sqrt(d))/(2*a)
x2 = (-b - math.sqrt(d))/(2*a)
print('1')
print('%.5f'%x1)
else:
print('2')
x1 = (-b + math.sqrt(d))/(2*a)
x2 = (-b - math.sqrt(d))/(2*a)
x1, x2 = min(x1, x2), max(x1, x2)
print('%.5f'%x1)
print('%.5f'%x2)
a, b, c = map(int, input().split())
solver(a, b, c)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
void roots(double a, double b, double c) {
double x1, x2;
double p = b * b - 4 * a * c;
if (a == 0 && b == 0 && c == 0)
cout << -1 << endl;
else if (p < 0 || a == 0 && b == 0)
cout << 0 << endl;
else if (a == 0) {
cout << 1 << endl;
cout << fixed << setprecision(6) << -1 * (c / b) << endl;
} else {
x1 = (-b + sqrt(p)) / (2 * a);
x2 = (-b - sqrt(p)) / (2 * a);
if (x1 > x2) {
cout << 2 << endl;
cout << fixed << setprecision(6) << x2 << endl << x1 << endl;
} else if (x2 > x1) {
cout << 2 << endl;
cout << fixed << setprecision(6) << x1 << endl << x2 << endl;
} else {
cout << 1 << endl;
cout << fixed << setprecision(6) << x1 << endl;
}
}
}
int main() {
double a, b, c;
cin >> a >> b >> c;
roots(a, b, c);
return 0;
}
| 8 |
CPP
|
a, b, c = map(int, input().split())
if a == 0: # line
if b == 0: # horizontal line
if c == 0: # along x axis
print(-1)
else:
print(0)
else: # slanted line
print(1)
print(-c / b)
else: # parabola
square = b*b - 4*a*c
if square < 0: # complex roots
print(0)
elif square == 0: # one root
print(1)
print(-b / (2 * a))
else: # two roots
print(2)
term = square ** 0.5
roots = sorted([(-b + term) / (2 * a), (-b - term) / (2 * a)])
print(roots[0])
print(roots[1])
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
while (cin >> a >> b >> c) {
if (a != 0) {
if (b * b - 4 * a * c < 0)
cout << 0 << endl;
else if (b * b - 4 * a * c == 0) {
printf("%d\n", 1);
printf("%.10lf\n", -b / (2 * a));
} else if (b * b - 4 * a * c > 0) {
cout << 2 << endl;
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));
}
}
} else if (b != 0) {
cout << 1 << endl;
printf("%.10lf\n", -c / b);
} else if (c != 0) {
cout << 0 << endl;
} else
cout << -1 << endl;
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
double ad = a;
double bd = b;
double cd = c;
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
return 0;
}
if (a == 0) {
if (b == 0) {
cout << 0 << endl;
return 0;
}
printf("1\n%.9lf\n", -cd / bd);
} else {
long long D = b * b - 4LL * a * c;
if (D < 0) {
cout << 0 << endl;
return 0;
}
if (D == 0) {
cout << 1 << endl;
printf("%.9lf\n", -bd / (2.0 * ad));
return 0;
}
vector<double> v;
v.push_back((-bd + sqrt((double)D)) / (2.0 * ad));
v.push_back((-bd - sqrt((double)D)) / (2.0 * ad));
sort(v.begin(), v.end());
cout << 2 << endl;
for (int i = 0; i < 2; i++) printf("%.9lf\n", v[i]);
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
double n, m, k, a, b, c;
string s;
vector<double> v;
int main() {
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 (b * b - 4 * a * c < 0) {
printf("0\n");
return 0;
}
if (a == 0) {
printf("1\n");
double cev = -c / b;
printf("%lf", cev);
return 0;
}
if (b * b - 4 * a * c == 0) {
printf("1\n");
double cev = -b / (2 * a);
printf("%lf", cev);
return 0;
}
printf("2\n");
double cev = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
double cevap = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
v.push_back(cev);
v.push_back(cevap);
sort(v.begin(), v.end());
printf("%lf\n", v[0]);
printf("%lf\n", v[1]);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
int a, b, c;
void solver() {
if (a == 0 && b != 0) {
printf("1\n%.5f\n", (-c / (float)b));
return;
}
if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
return;
}
if ((a == 0 && b == 0 && c != 0) || (a == b && b == c) ||
(b == 0 && a * c > 0)) {
printf("0\n");
return;
}
if (a * b * 4 == b * b && c != 0) {
printf("1\n%.5f\n", (-b / (float)(2 * a)));
return;
}
double discriminante = sqrt((double)b * b - (double)4 * a * c);
double v1 = (-b - discriminante) / (double)(2 * a);
double v2 = (-b + discriminante) / (double)(2 * a);
if (v1 < v2)
printf("2\n%.5lf\n%.5lf\n", v1, v2);
else {
if (v1 != v2)
printf("2\n%.5lf\n%.5lf\n", v2, v1);
else
printf("1\n%.5lf\n", v1);
}
}
int main() {
while (scanf("%d %d %d", &a, &b, &c) != EOF) solver();
return 0;
}
| 8 |
CPP
|
import re
arr = re.split(' ', input())
A = int(arr[0])
B = int(arr[1])
C = int(arr[2])
dis = B*B-4*A*C
if (A == 0 and B == 0 and C == 0):
print(-1)
elif (A == 0 and B == 0):
print(0)
elif (A == 0):
print(1)
print(-C/B)
elif (dis<0):
print(0)
elif (dis==0):
print(1)
print(-B/(2*A))
else:
print(2)
if (A>0):
print((-B-dis**0.5)/(2*A))
print((-B+dis**0.5)/(2*A))
else:
print((-B+dis**0.5)/(2*A))
print((-B-dis**0.5)/(2*A))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
const int MAX1 = 0x7f7f7f7f;
const int MAX = 1e5 + 10;
double exgcd(long long l, long long r, double &x, double &y) {
if (r == 0) {
x = 1;
y = 0;
return l;
} else {
double d = exgcd(r, l % r, y, x);
y -= l / r * x;
return d;
}
}
int main() {
int n, m;
int i, j, k;
int ans;
double a, b, c, res1, res2;
double num[20];
memset(num, 0, sizeof(num));
scanf("%lf%lf%lf", &a, &b, &c);
double flag = b * b - 4 * (a * c);
if (a == 0 && c == 0 && b == 0)
printf("-1\n");
else if (a == 0 && b != 0) {
ans = 1;
res1 = (-c) * 1.0 / b;
printf("%d\n%.10lf\n", ans, res1);
} else if (a == 0 && b == 0 && c != 0)
printf("0\n");
else {
if (b * b - 4 * (a * c) < 0) {
printf("0\n");
} else if (b * b - 4 * (a * c) == 0) {
ans = 1;
res1 = -b / (2 * a);
printf("%d\n%.10lf\n", ans, res1);
} else {
ans = 2;
res1 = (-b - sqrt(flag * 1.0)) / (2 * a);
res2 = (-b + sqrt(flag * 1.0)) / (2 * a);
if (res1 > res2) {
flag = res1;
res1 = res2;
res2 = flag;
}
printf("%d\n%.10lf\n%.10lf\n", ans, res1, res2);
}
}
return 0;
}
| 8 |
CPP
|
#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;
else if (a == 0 && b == 0 && c != 0)
cout << 0;
else if (b * b - 4 * a * c < 0)
cout << 0;
else if (a == 0) {
cout << 1 << endl;
double x = -(c / b);
printf("%.10f", x);
} else {
double x = ((-b) + sqrt(b * b - 4 * a * c)) / (2 * a);
double y = ((-b) - sqrt(b * b - 4 * a * c)) / (2 * a);
if (x == y) {
cout << 1 << endl;
printf("%.10f", x);
} else {
cout << 2 << endl;
if (x > y) swap(x, y);
printf("%.10f", x);
cout << endl;
printf("%.10f", y);
}
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int const uu[4] = {1, -1, 0, 0};
int const vv[4] = {0, 0, 1, -1};
int const inf = 0x3f3f3f3f;
long long const INF = 0x7fffffffffffffffll;
double eps = 1e-10;
double pi = acos(-1.0);
double a, b, c;
int main() {
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0) {
puts("-1");
return 0;
} else {
puts("0");
return 0;
}
} else {
printf("1\n%.10lf\n", (-c) / b);
return 0;
}
}
double delta = b * b - 4 * a * c;
if (delta < 0.0) {
puts("0");
return 0;
}
delta = sqrt(delta);
double x1 = (-b - delta) / (2 * a);
double x2 = (-b + delta) / (2 * a);
if (fabs(x1 - x2) < eps) {
puts("1");
printf("%.10lf\n", x1);
return 0;
}
if (x1 > x2) swap(x1, x2);
puts("2");
printf("%.10lf\n", x1);
printf("%.10lf\n", x2);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else {
cout << 1 << endl;
printf("%.9lf\n", -c / b);
}
} else {
if (b * b - 4 * a * c < 0) {
cout << 0 << endl;
return 0;
}
double root1, root2;
root1 = (-b + pow(b * b - 4 * a * c, 0.5)) / (2 * a);
root2 = (-b - pow(b * b - 4 * a * c, 0.5)) / (2 * a);
if (root1 == root2) {
cout << 1 << endl;
printf("%.9lf\n", root1);
} else {
cout << 2 << endl;
if (root1 > root2) swap(root1, root2);
printf("%.9lf\n", root1);
printf("%.9lf\n", root2);
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a == 0 && b == 0 && c == 0)
printf("%d", -1);
else if (a == 0 && b == 0 && c != 0)
printf("%d", 0);
else if (a == 0 && b != 0)
printf("1\n%.10lf", -double(c) / b);
else {
if (b * b - 4 * a * c < 0)
printf("0");
else if (b * b - 4 * a * c == 0) {
printf("1\n");
double x = double(-b) / 2 / a;
printf("%.10lf", x);
} else {
printf("2\n");
double x1 = double(-b + sqrt(b * b - 4 * a * c)) / 2 / a;
double x2 = double(-b - sqrt(b * b - 4 * a * c)) / 2 / a;
double t;
if (x1 > x2) t = x1, x1 = x2, x2 = t;
printf("%.10lf\n%.10lf", x1, x2);
}
}
return 0;
}
| 8 |
CPP
|
R=lambda:map(int,input().split())
(a,b,c) = R()
if b:
t = [1,-c/b]
else:
t = [-(c==0)]
if a:
(d,x) = ((b*b)-(4*a*c),-2*a)
if d:
if d < 0:
t = [0]
else:
t = [2] + sorted([(b - d ** 0.5) / x, (b + d ** 0.5)/x])
else:
t = [1,b/x]
if len(t)==1:
print(*t)
elif len(t)==2:
print(t[0])
print('%.10f'%t[1])
else:
print(t[0])
print('%.10f'%t[1])
print('%.10f'%t[2])
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
float dir, x1, x2;
int count;
while (cin >> a >> b >> c) {
if (a == 0 && b == 0 && c == 0)
cout << "-1" << endl;
else if (a == 0) {
if (b == 0)
cout << "0" << endl;
else {
cout << "1" << endl;
printf("%.5f\n", -(float)c / (float)b);
}
} else {
dir = b * b - 4 * a * c;
if (dir < 0)
cout << "0" << endl;
else {
if (dir > 0) count = 2;
if (dir == 0) count = 1;
dir = sqrt(dir);
x1 = (-b + dir) / (2 * a);
x2 = (-b - dir) / (2 * a);
if (x1 > x2) swap(x1, x2);
if (count == 1) printf("%d\n%.5f\n", count, x1);
if (count == 2) printf("%d\n%.5f\n%.5f\n", count, x1, x2);
}
}
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1;
else
cout << 0;
} else
cout << fixed << setprecision(5) << "1\n" << -c / b;
} else {
double denta = b * b - 4 * a * c;
if (denta < 0)
cout << 0;
else if (denta == 0)
cout << "1\n" << fixed << setprecision(5) << -b / 2 / a;
else {
double x1 = (-b - sqrt(denta)) / 2 / a, x2 = (-b + sqrt(denta)) / 2 / a;
if (x1 > x2) {
double temp = x1;
x1 = x2;
x2 = temp;
}
cout << "2\n"
<< fixed << setprecision(5) << x1 << "\n"
<< fixed << setprecision(5) << x2;
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0 && c == 0) {
cout << "-1" << endl;
return 0;
}
if (b == 0 && c != 0) {
cout << "0" << endl;
return 0;
}
cout << "1" << endl;
cout << fixed << setprecision(10) << -c / b << endl;
} else {
if (b * b - 4 * a * c < 0) {
cout << "0" << endl;
return 0;
}
if (b * b - 4 * a * c == 0) {
cout << "1" << endl;
cout << fixed << setprecision(10) << -b / 2 / a << endl;
}
if (b * b - 4 * a * c > 0) {
cout << "2" << endl;
cout << fixed << setprecision(10);
cout << min((-b - sqrt(b * b - 4 * a * c)) / 2 / a,
(-b + sqrt(b * b - 4 * a * c)) / 2 / a)
<< endl;
cout << max((-b - sqrt(b * b - 4 * a * c)) / 2 / a,
(-b + sqrt(b * b - 4 * a * c)) / 2 / a)
<< endl;
}
}
return 0;
}
| 8 |
CPP
|
#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.0) {
if (b == 0.0) {
if (c == 0.0)
cout << "-1" << endl;
else
cout << "0" << endl;
return 0;
}
cout << "1" << endl;
cout << fixed << setprecision(20) << -c / b << endl;
return 0;
}
if (d < 0.0) return cout << "0" << endl, 0;
if (d == 0.0) {
cout << "1" << endl;
cout << fixed << setprecision(20) << -1 * b / a / 2.0 << endl;
return 0;
}
double k = sqrt(d);
cout << "2" << endl;
if (a > 0.0) {
cout << fixed << setprecision(20) << (-b - k) / (2 * a) << endl;
cout << fixed << setprecision(20) << (-b + k) / (2 * a) << endl;
} else {
cout << fixed << setprecision(20) << (-b + k) / (2 * a) << endl;
cout << fixed << setprecision(20) << (-b - k) / (2 * a) << endl;
}
return 0;
}
| 8 |
CPP
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.