-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1036.cpp
36 lines (26 loc) · 782 Bytes
/
1036.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// https://judge.beecrowd.com/en/problems/view/1036
/*
Time Complexity =>
Space Complexity =>
*/
#include <bits/stdc++.h>
using namespace std;
bool isInvalid(double x) { return isnan(x) || isinf(x); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ifstream input("input.txt");
ofstream output("output.txt");
double a = 0, b = 0, c = 0;
cin >> a >> b >> c;
double x1 = (-b + (sqrt(pow(b, 2) - (4 * a * c)))) / (2 * a);
double x2 = (-b - (sqrt(pow(b, 2) - (4 * a * c)))) / (2 * a);
if (isInvalid(x1) || isInvalid(x2)) {
cout << "Impossivel calcular" << endl;
} else {
cout << "R1 = " << fixed << setprecision(5) << x1 << endl;
cout << "R2 = " << fixed << setprecision(5) << x2 << endl;
}
return 0;
}