0% found this document useful (0 votes)
5 views2 pages

Output Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Output Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>
#include <math.h>

int main() {
long long a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
long long delta = b * b - 4 * a * c;

if (a == 0 && b != 0 && c != 0) {
printf("%.9f\n", (double)-c / b);
printf("1\n");
} else if (a != 0 && b == 0 && c == 0) {
printf("1\n%.9f\n", 0.0);
} else if (a == 0 && b == 0 && c != 0) {
printf("0\n");
} else if (a == 0 && b != 0 && c == 0) {
printf("1\n%.9f\n", 0.0);
} else if (a != 0 && b != 0 && c == 0) {
printf("2\n");
if ((double)(-b / a) > 0) {
printf("%.9f\n", 0.0);
printf("%.9f\n", (double)-b / a);
} else {
printf("%.9f\n", (double)-b / a);
printf("%.9f\n", -0.0);
}
} else if (a == 0 && b == 0 && c == 0) {
printf("-1\n");
} else if (a != 0 && b == 0 && c != 0) {
if ((double)-c / a > 0) {
printf("2\n");
double x1 = sqrt((double)-c / a);
double x2 = sqrt((double)-c / a);
if (x1 > x2) {
printf("%.9f\n", x2);
printf("%.9f\n", x1);
} else {
printf("%.9f\n", x1);
printf("%.9f\n", x2);
}
} else {
printf("0\n");
}
} else if (a == b && b == c) {
printf("0\n");
} else if (delta < 0) {
printf("0\n");
} else if (delta == 0) {
printf("%.9f\n", (double)(-b / (2 * a)));
printf("1\n");
} else {
double x1 = (double)(-b - sqrt(delta)) / (2 * a);
double x2 = (double)(-b + sqrt(delta)) / (2 * a);
printf("2\n");
if (x1 > x2) {
printf("%.9f\n", x2);
printf("%.9f\n", x1);
} else {
printf("%.9f\n", x1);
printf("%.9f\n", x2);
}
}

return 0;
}

You might also like