#38813: 比較特殊的解答


wuj35060@gmail.com (412441171)


#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int discriminant = b * b - 4 * a * c;

    if (discriminant > 0) {
        int x1 = (-b + sqrt(discriminant)) / (2 * a);
        int x2 = (-b - sqrt(discriminant)) / (2 * a);
        cout << "Two different roots x1=" << max(x1, x2) << " , x2=" << min(x1, x2) << endl;
    } else if (discriminant == 0) {
        int x = -b / (2 * a);
        cout << "Two same roots x=" << x << endl;
    } else {
        cout << "No real root" << endl;
    }

    return 0;
}