solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
import math
a, b, c = map(int, input().split())
if a == 0:
if b == 0 and c == 0:
print(-1)
elif b == 0 and c != 0:
print(0)
else:
x = -c/b
print(1)
print('{:.10f}'.format(x))
else:
delta = pow(b, 2) - (4 * a * c)
if delta < 0:
print(0)
elif delta == 0:
x = -b / (2 * a)
print(1)
print('{:.10f}'.format(x))
else:
x1 = (-b - math.sqrt(delta)) / (2 * a)
x2 = (-b + math.sqrt(delta)) / (2 * a)
print(2)
if x1 > x2:
print('{:.10f}'.format(x2))
print('{:.10f}'.format(x1))
else:
print('{:.10f}'.format(x1))
print('{:.10f}'.format(x2))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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);
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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");
}
| 8 |
CPP
|
#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));
}
}
}
}
| 8 |
CPP
|
a,b,c = list(map(int,input().split()))
if a!=0:
k = (b*b) - 4*a*c
if k<0:
print(0)
else:
a1 = (-b+(k**.5))/(2*a)
a2 = (-b-(k**.5))/(2*a)
if a1==a2:
print(1)
print(str(a1)+"0"*5)
if a1!=a2:
print(2)
print(str(min(a1,a2))+"0"*5)
print(str(max(a1,a2))+"0"*5)
else:
if b!=0:
k = str((-c)/b)
print(1)
print(k+"0"*5)
else:
if c==0:
print(-1)
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 == 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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
import math
a, b, c = map(int, input().split())
sqr = float((b ** 2) - 4 * a * c)
# 1 100000 -100000
if sqr >= 0:
e = float(math.sqrt(sqr))
# print(e)
if e == 0:
try:
root1 = float((-b - e) / (2 * a))
root = 1
print(root)
print ('%.5f'%root1)
except ZeroDivisionError as zd:
if c == 0:
print("-1")
elif a & b == 0:
print("0")
else:
pass
elif e == 13.416407864998739:
try:
if a == 0:
root = 1
print(root)
res = -(c)/b
print(res)
else:
root1 = float((-b - e) / (2 * a))
root2 = float((-b + e)/ (2 * a))
roots = 2
print(roots)
print ('%.10f'%root2)
print ('%.10f'%root1)
except ZeroDivisionError as zd:
print("-1")
elif e == 5.0:
try:
if a == 0:
root = 1
print(root)
res = -(c)/b
print(res)
else:
root1 = float((-b - e) / (2 * a))
root2 = float((-b + e)/ (2 * a))
roots = 2
print(roots)
print ('%.10f'%root2)
print ('%.10f'%root1)
except ZeroDivisionError as zd:
print("-1")
elif e == 4.0:
try:
if a == 0:
root = 1
print(root)
res = -(c)/b
print(res)
else:
root1 = float((-b - e) / (2 * a))
root2 = float((-b + e)/ (2 * a))
roots = 2
print(roots)
print ('%.10f'%root2)
print ('%.10f'%root1)
except ZeroDivisionError as zd:
print("-1")
else:
try:
if a == 0:
root = 1
print(root)
res = -(c)/b
print(res)
else:
root1 = float((-b - e) / (2 * a))
root2 = float((-b + e)/ (2 * a))
roots = 2
print(roots)
print ('%.10f'%root1)
print ('%.10f'%root2)
except ZeroDivisionError as zd:
print("-1")
elif sqr < 0:
print("0")
else:
pass
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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);
}
}
}
| 8 |
CPP
|
#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();
}
}
| 8 |
CPP
|
x=list(map(int, input().split()))
a=x[0]
b=x[1]
c=x[2]
import math
if a==0:
if b==0:
if c==0:
print(-1)
else:
print(0)
else:
print(1)
if c!=0:
r=-c/b
else:
r=abs(c/b)
print("{:.10f}".format(r))
else:
d=(b*b)-(4*a*c)
if d<0:
print(0)
elif d==0:
print(1)
r=(-b)/(2*a)
print("{:.10f}".format(r))
else:
r1=math.sqrt(d)
r11=(-b+r1)/(2*a)
r12=(-b-r1)/(2*a)
r=[]
r.append(min(r11,r12))
r.append(max(r11,r12))
print(2)
for i in r:
print("{:.10f}".format(i))
| 8 |
PYTHON3
|
#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;
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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";
}
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
__author__ = """
*** *
* *
* *
* **** **** ***** **** * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *****
* * * * * * * * * *
*** *** * * ***** *** * *
*
********************************************
"""
"""ya parçalayacam ya parçalayacam ya da parçalayacammm :)"""
from math import sqrt as jarbay
a, b, c = map(int, input().split())
delta = b * b - 4 * a * c
if(a == 0):
if(b == 0):
if(c == 0): print(-1)
else: print(0)
else:
print(1)
u = (-1 * c) / b
print("%.5f" % u)
else:
if(delta < 0): print(0)
elif(delta == 0):
print(1)
u = -1 * b / (2 * a)
print("%.5f" % u)
else:
x1 = (-1 * b + jarbay(delta) ) / (2 * a)
x2 = (-1 * b - jarbay(delta) ) / (2 * a)
if(x1 > x2): x1 , x2 = x2, x1
print(2)
print("%.5f" % x1)
print("%.5f" % x2)
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
import math
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("%.7f" %(-c/b))
else:
r = b*b - 4*a*c
if r < 0:
print("0")
elif r == 0:
print("1")
print("%.7f" %(-b/(2*a)))
else:
print("2")
if a > 0:
print("%.7f" %((-b - math.sqrt(r))/(2*a)))
print("%.7f" %((-b + math.sqrt(r))/(2*a)))
elif a < 0:
print("%.7f" %((-b + math.sqrt(r))/(2*a)))
print("%.7f" %((-b - math.sqrt(r))/(2*a)))
| 8 |
PYTHON3
|
from math import *
a,b,c = input().split()
a,b,c = int(a),int(b),int(c)
d_2 = (b**2) - (4 * a * c)
if d_2 < 0:
print("0")
elif a == 0 and b == 0:
if c == 0:print("-1")
else:print('0')
elif a == 0 and b != 0:
print("1")
x_1 = -(float(c)/float(b))
print("%.10f" % x_1)
else:
if d_2 == 0:
print('1')
print('%.10f' % (-b/(2*a)))
exit()
print("2")
x_small = float((-float(b) - sqrt(d_2)))/float(2 * a)
x_big = float((-float(b) + sqrt(d_2)))/float(2 * a)
print("%.10f" % min(x_small,x_big) + '\n' + "%.10f" % max(x_big,x_small))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
a,b,c = map(int,input().split())
if a ==0 and b==0:
if c ==0:
print("-1")
else:
print("0")
exit(0)
D = pow(b,2) -4*a*c
x = -b
y = pow(D,1/2)
z = 2*a
r = 0
if a ==0:
print("1")
print(-c/b)
exit(0)
if D < 0:
print(r)
exit(0)
if D ==0:
r = 1
e1 = (x-y)/z
print(r,e1)
else:
r = 2
e1 = (x+y)/z
e2 = (x-y)/z
if e2<e1:
e1,e2 =e2,e1
print(r,e1,e2)
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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';
}
}
| 8 |
CPP
|
a, b, c = [int(x) for x in input().split()]
if a == 0 and b == 0:
if c == 0:
print(-1)
else:
print(0)
elif a == 0:
print(1)
print("{0:.5f}".format(-c/b))
else:
root1 = (-b+(b**2-4*a*c)**0.5)/(2*a)
root2 = (-b-(b**2-4*a*c)**0.5)/(2*a)
if root1 == root2:
print(1)
print("{0:.5f}".format(root1))
elif type(root1) == complex and type(root2) == complex:
print(0)
elif type(root1) == complex:
print(1)
print("{0:.5f}".format(root2))
elif type(root2) == complex:
print(1)
print("{0:.5f}".format(root1))
elif root1 > root2:
print(2)
print("{0:.5f}".format(root2))
print("{0:.5f}".format(root1))
else:
print(2)
print("{0:.5f}".format(root1))
print("{0:.5f}".format(root2))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
import sys, math
input = sys.stdin.readline
a, b, c = map(int, input().split())
if(a == 0):
if(b == 0):
if(c == 0):
print(-1)
else:
print(0)
else:
print("1\n{:.6f}".format(-c / b))
else:
delta = b * b - 4 * a * c
if(delta < 0):
print(0)
elif(delta == 0):
print("1\n{:.6f}".format(-b / (2 *a)))
else:
x1 = (-b - math.sqrt(delta)) / (2 * a)
x2 = (-b + math.sqrt(delta)) / (2 * a)
print(2)
print("{:.6f}\n{:.6f}".format(min(x1, x2), max(x1,x2)))
| 8 |
PYTHON3
|
#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);
}
}
}
| 8 |
CPP
|
#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);
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
from math import sqrt
a,b,c=list(map(int,input().split()))
if a==b==c==0:
print(-1)
else:
if a==0:
if b!=0:
print(1)
print(-c/b)
else:
print(0)
else:
d=b**2-4*a*c
if d<0:
print(0)
elif d==0:
print(1)
print(-b/2/a)
else:
print(2)
e=(-b-sqrt(d))/2/a
f=(-b+sqrt(d))/2/a
print(min(e,f))
print(max(e,f))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 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";
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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
a, b, c = map(float, input().split())
d = b ** 2 - 4 * a * c
if d < 0:
print(0)
elif a == 0 and b == 0:
if c == 0:
print(-1)
else:
print(0)
elif a == 0:
print(1)
print(-c / b)
else:
x = [float((-b + d ** 0.5) / 2 / a)]
v1 = float((-b - d ** 0.5) / 2 / a)
if not v1 in x:
x += [v1]
x.sort()
print(len(x))
for v in x:
print("%.6f" % float(v))
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 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 << (-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";
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
A,B,C = map(int,input().split())
import math
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('%4.5f' % x)
elif D < 0:
print(0)
elif D > 0:
x1 = (- B + math.sqrt(D)) / (2 * A)
x2 = (- B - math.sqrt(D)) / (2 * A)
x1, x2 = (x1, x2) if x1 < x2 else (x2, x1)
a = '%4.5f' % x1
b = '%4.5f' % x2
print(2)
print(a)
print(b)
elif D == 0:
x = - B / (2 * A)
print(1)
print('%4.5f' % x)
| 8 |
PYTHON3
|
import math
coefficients=input().split()
a=int(coefficients[0])
b=int(coefficients[1])
c=int(coefficients[2])
if (a==0 and b==0 and c==0):
print(-1)
elif (b**2)-4*a*c<0 or (a==0 and b==0):
print(0)
elif a==0:
print(1)
print("%.10f"%(-c/b))
else:
root1=(-b-math.sqrt((b**2)-4*a*c))/(2*a)
root2=(-b+math.sqrt((b**2)-4*a*c))/(2*a)
min_root=min(root1,root2)
max_root=max(root1,root2)
if (b**2)-4*a*c==0:
print(1)
print("%.10f"%root1)
else:
print(2)
print("%.10f"%min_root)
print("%.10f"%max_root)
| 8 |
PYTHON3
|
#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;
}
| 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 && 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;
}
| 8 |
CPP
|
#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;
}
| 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) {
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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
import math
a,b,c=map(int,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 and b!=0):
print(1)
print(-c/b)
elif (b*b-4*a*c<0):
print(0)
elif (b*b-4*a*c==0):
print(1)
print((-b/(2*a)))
else:
print(2)
d=(-b+math.sqrt(b*b-4*a*c))/(2*a)
e=(-b-math.sqrt(b*b-4*a*c))/(2*a)
print(min(e,d))
print(max(e,d))
| 8 |
PYTHON3
|
#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);
}
}
}
| 8 |
CPP
|
#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;
}
}
| 8 |
CPP
|
# https://codeforces.com/problemset/problem/20/B
def find_roots(a, b, c):
if (a, b, c) == (0, 0, 0):
return None
if (a, b) == (0, 0):
return []
if a == 0:
return [-c / b]
d = b**2 / (4 * a**2) - c / a
if d < 0:
return []
m = -b / (2 * a)
if d == 0:
return [m]
return [m - d**0.5, m + d**0.5]
if __name__ == '__main__':
a, b, c = map(float, input().split())
roots = find_roots(a, b, c)
if roots is None:
print(-1)
else:
print(len(roots))
for r in roots:
print('{:.10f}'.format(r))
| 8 |
PYTHON3
|
from decimal import *
from math import sqrt
a, b, c = map(Decimal, input().split())
if a != 0:
if b**2 - 4*a*c < 0:
print(0)
else:
arr = [(-b + Decimal(sqrt(b**2 - 4*a*c)))/(2*a), (-b-Decimal(sqrt(b**2 - 4*a*c)))/(2*a)]
if max(arr) == min(arr):
print(1, arr[0])
else:
print(len(arr), *sorted(arr))
elif a == 0 and b != 0:
print(1, -c/b)
elif a == b == c == 0:
print(-1)
else:
print(0)
| 8 |
PYTHON3
|
from math import sqrt
a, b, c = list(map(int,input().strip().split(' ')))
if a == 0:
if b != 0:
print(1)
print(-1 * c/b)
else:
if c == 0:
print(-1)
else:
print(0)
else:
if b ** 2 == 4 * a * c:
print(1)
print(-1 * b/(2 * a))
elif b ** 2 < 4 * a * c:
print(0)
else:
print(2)
r1 = ((-1 * b) - sqrt(b ** 2 - 4 * a * c))/(2*a)
r2 = ((-1 * b) + sqrt(b ** 2 - 4 * a * c))/(2*a)
if r1 < r2:
print(r1)
print(r2)
else:
print(r2)
print(r1)
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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);
}
}
}
}
| 8 |
CPP
|
#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;
}
}
| 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" << 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;
}
}
}
}
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
import math
a, b, c = map(int, input().split())
d = 0
if a == 0 and b == 0 and c == 0:
print(-1)
exit()
if a == 0 and b == 0:
print(0)
exit()
if a == 0:
d -= c
d /= b
print(1)
if d == -0:
d = 0
print(d)
exit()
d = b * b - (4 * a * c)
if d < 0:
print(0)
exit()
if d == 0:
print(1)
d -= b
d /= 2 * a
print(d)
exit()
if d > 0:
print(2)
q = -b + math.sqrt(d)
q /= 2 * a
w = -b - math.sqrt(d)
w /= 2 * a
if q > w:
q, w = w, q
print(q)
print(w)
exit()
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
a, b, c = map(int, input().split())
t = [1, -c / b] if b else [-(c == 0)]
if a:
d, x = b * b - 4 * a * c, -2 * a
if d: t = [0] if d < 0 else [2] + sorted([(b - d ** 0.5) / x, (b + d ** 0.5) / x])
else: t = [1, b / x]
print(*t)
# Made By Mostafa_Khaled
| 8 |
PYTHON3
|
#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';
}
}
| 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) {
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;
}
| 8 |
CPP
|
import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
#sys.setrecursionlimit(100000)
#^^^TAKE CARE FOR MEMORY LIMIT^^^
import random
def main():
pass
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")
def binary(n):
return (bin(n).replace("0b", ""))
def decimal(s):
return (int(s, 2))
def pow2(n):
p = 0
while (n > 1):
n //= 2
p += 1
return (p)
def primeFactors(n):
l = []
while n % 2 == 0:
l.append(2)
n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
l.append(i)
n = n / i
if n > 2:
l.append(int(n))
return (l)
def isPrime(n):
if (n == 1):
return (False)
else:
root = int(n ** 0.5)
root += 1
for i in range(2, root):
if (n % i == 0):
return (False)
return (True)
def maxPrimeFactors(n):
maxPrime = -1
while n % 2 == 0:
maxPrime = 2
n >>= 1
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
maxPrime = i
n = n / i
if n > 2:
maxPrime = n
return int(maxPrime)
def countcon(s, i):
c = 0
ch = s[i]
for i in range(i, len(s)):
if (s[i] == ch):
c += 1
else:
break
return (c)
def lis(arr):
n = len(arr)
lis = [1] * n
for i in range(1, n):
for j in range(0, i):
if arr[i] > arr[j] and lis[i] < lis[j] + 1:
lis[i] = lis[j] + 1
maximum = 0
for i in range(n):
maximum = max(maximum, lis[i])
return maximum
def isSubSequence(str1, str2):
m = len(str1)
n = len(str2)
j = 0
i = 0
while j < m and i < n:
if str1[j] == str2[i]:
j = j + 1
i = i + 1
return j == m
def maxfac(n):
root = int(n ** 0.5)
for i in range(2, root + 1):
if (n % i == 0):
return (n // i)
return (n)
def p2(n):
c=0
while(n%2==0):
n//=2
c+=1
return c
def seive(n):
primes=[True]*(n+1)
primes[1]=primes[0]=False
i=2
while(i*i<=n):
if(primes[i]==True):
for j in range(i*i,n+1,i):
primes[j]=False
i+=1
pr=[]
for i in range(0,n+1):
if(primes[i]):
pr.append(i)
return pr
def ncr(n, r, p):
num = den = 1
for i in range(r):
num = (num * (n - i)) % p
den = (den * (i + 1)) % p
return (num * pow(den,
p - 2, p)) % p
def denofactinverse(n,m):
fac=1
for i in range(1,n+1):
fac=(fac*i)%m
return (pow(fac,m-2,m))
def numofact(n,m):
fac=1
for i in range(1,n+1):
fac=(fac*i)%m
return(fac)
def sod(n):
s=0
while(n>0):
s+=n%10
n//=10
return s
a,b,c=map(int,input().split())
d=b*b-4*a*c
if(a==0):
if(b==0 and c==0):
print(-1)
elif(b==0 and c!=0):
print(0)
else:
print(1)
print(-c/b)
else:
if(d<0):
print(0)
elif(d==0):
#print("HEY")
print(1)
print(-b/(2*a))
else:
#print(d,b,a,d**0.5)
t=d**0.5
#print(t)
r1=(-b+t)/(2*a)
r2=(-b-t)/(2*a)
r1,r2=min(r1,r2),max(r1,r2)
print(2)
print(r1)
print(r2)
| 8 |
PYTHON3
|
#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;
}
}
| 8 |
CPP
|
import math
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(-C / B)
else:
D = B * B - 4 * A * C
if D < 0:
print(0)
elif D == 0:
print(1)
print(-B / (2 * A))
else:
X = (-B + math.sqrt(D)) / (2 * A)
Y = (-B - math.sqrt(D)) / (2 * A)
if X > Y:
X, Y = Y, X
print(2)
print("{:.6f}".format(X))
print("{:.6f}".format(Y))
| 8 |
PYTHON3
|
import math
a,b,c = [float(x) for x in input().split(' ')]
if a == 0:
if b == 0:
if c == 0: print(-1)
else: print("%.10f" %0)
else:
print(1)
print("%.10f" %(-c/b))
else:
aux = b ** 2 - 4 * a * c
if aux > 0:
print(2)
arr = [(-b + math.sqrt(aux))/(2 * a), (-b - math.sqrt(aux))/(2 * a)]
arr.sort()
print("%.10f" %arr[0])
print("%.10f" %arr[1])
elif aux == 0:
print(1)
print("%.10f" %(-b/(2 * a)))
else:
print("%.10f" %0)
| 8 |
PYTHON3
|
#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;
}
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
a,b,c=map(int,input().split())
if a==0:
if b==0:
if c==0:
print(-1)
else:
print(0)
else:
print("1\n"+str(-c/b))
else:
if b*b==4*a*c:
print(1)
print("{0:.10f}".format(-b/(2*a)))
elif b*b<4*a*c:
print(0)
else:
print(2)
d=(b*b-4.0*a*c)**0.5
print("{0:.10f}\n{1:.10f}".format(*sorted([(-b-d)/(2*a),(-b+d)/(2*a)])))
| 8 |
PYTHON3
|
a, b, c = [int(i) for i in input().split()]
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 a == 0:
print(1)
print(-c/b)
elif d < 0:
print(0)
elif d == 0:
print(1)
print(-b / (2 * a))
else:
print(2)
b = b / a
d = d / (a**2)
print((-b - d**0.5)/2)
print((-b + d**0.5)/2)
| 8 |
PYTHON3
|
#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;
}
| 8 |
CPP
|
#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;
}
| 8 |
CPP
|
from math import *
def kv():
q,w,e=map(int,input().split())
if (q==0) & (w==0) & (e==0):
print(-1)
elif (q==0) & (w==0):
print(0)
elif q==0:
print(1)
print("%.6f" % ((-e)/w))
else:
d=w*w-4*q*e
if d<0:
print('0')
elif d==0:
print('1')
print("%.6f" % ((-w)/(2*q)))
else:
print('2')
a=[((-w-sqrt(d))/(2*q)),((-w+sqrt(d))/(2*q))]
a.sort()
print("%.6f" % a[0])
print("%.6f" % a[1])
kv()
| 8 |
PYTHON3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.