#include <iostream>
#include <cmath>
int main()
{
double p, q, u, v;
double a = 1.0, b = -6.0, c = 11.0, d = -6.0;
p = (3.0 * a * c - b * b) / (3.0 * a * a); // (3ac - b^2) / 3a^2
q = (27.0 * a * a * d + 2.0 * b * b * b - 9.0 * a * b * c) / (27.0 * a * a * a); // (27.0 * a^2 * d + 2 * b^3 -9.0 * a * b * c) / 27a^3
std::cout << "p = " << p << ", q = " << q << std::endl;
u = std::pow(-q / 2.0 + std::sqrt(std::pow(q / 2.0, 2.0) + std::pow(p / 3.0, 3.0)), 1.0 / 3.0); // (-q/2 + √((q/2)^2 + (p/3)^3))^(1/3)
v = std::pow(-q / 2.0 - std::sqrt(std::pow(q / 2.0, 2.0) + std::pow(p / 3.0, 3.0)), 1.0 / 3.0); // (-q/2 - √((q/2)^2 + (p/3)^3))^(1/3)
double x1, x2, x3;
x1 = u + v + b / (3.0 * a);
std::cout << "x1 = " << x1 << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CgppbnQgbWFpbigpCnsKICBkb3VibGUgcCwgcSwgdSwgdjsKICBkb3VibGUgYSA9IDEuMCwgYiA9IC02LjAsIGMgPSAxMS4wLCBkID0gLTYuMDsKICAKICBwID0gKDMuMCAqIGEgKiBjIC0gYiAqIGIpIC8gKDMuMCAqIGEgKiBhKTsgLy8gKDNhYyAtIGJeMikgLyAzYV4yCiAgcSA9ICgyNy4wICogYSAqIGEgKiBkICsgMi4wICogYiAqIGIgKiBiIC0gOS4wICogYSAqIGIgKiBjKSAvICgyNy4wICogYSAqIGEgKiBhKTsgLy8gKDI3LjAgKiBhXjIgKiBkICsgMiAqIGJeMyAtOS4wICogYSAqIGIgKiBjKSAvIDI3YV4zCiAgCiAgc3RkOjpjb3V0IDw8ICJwID0gIiA8PCBwIDw8ICIsIHEgPSAiIDw8IHEgPDwgc3RkOjplbmRsOwogIAogIHUgPSBzdGQ6OnBvdygtcSAvIDIuMCArIHN0ZDo6c3FydChz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