#include <iostream>
#include <vector>
#include <cmath>
#include <stdexcept>

std::vector<double> solve_equation(double a, double b, double c) {
    if (a == 0) {
        if (b == 0) {
            throw std::runtime_error("No solution or infinite solutions.");
        }
        return {-c / b};
    }

    double discriminant = b*b - 4*a*c;
    
    if (discriminant > 0) {
        double x1 = (-b + std::sqrt(discriminant)) / (2*a);
        double x2 = (-b - std::sqrt(discriminant)) / (2*a);
        return {x1, x2};
    } else if (discriminant == 0) {
        return {-b / (2*a)};
    } else {
        throw std::runtime_error("No real roots.");
    }
}

int main() {
    try {
        std::vector<double> roots = solve_equation(1, -3, 2);
        std::cout << "Roots for a=1, b=-3, c=2 are: ";
        for (double root : roots) {
            std::cout << root << " ";
        }
        std::cout << std::endl;
    } catch (const std::runtime_error& e) {
        std::cerr << "Error: " << e.what() << std::endl;
    }
    return 0;
}
