1 solutions
-
1
赖皮公式代入法:#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> double a, b, c, d, cnt = 0; double as, bs, t, si; double x1, x2, x3; int main() { std::cin >> a >> b >> c >> d; as = b * b - 3 * a * c; bs = b * c - 9 * a * d; t = (2 * as * b - 3 * a * bs) / (2 * sqrt(as * as * as)); si = acos(t); x1 = (- b - 2 * sqrt(as) * cos(si / 3)) / (3 * a); x2 = (- b + sqrt(as) * (cos(si / 3) + sqrt(3) * sin(si / 3))) / (3 * a); x3 = (- b + sqrt(as) * (cos(si / 3) - sqrt(3) * sin(si / 3))) / (3 * a); if(x1 > x2) { double t = x1; x1 = x2; x2 = t; } if(x1 > x3) { double t = x1; x1 = x3; x3 = t; } if(x2 > x3) { double t = x2; x2 = x3; x3 = t; } printf("%.2f %.2f %.2f", x1, x2, x3); return 0; }
- 1
Information
- ID
- 24
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 2
- Tags
- # Submissions
- 5
- Accepted
- 5
- Uploaded By