kyopro-lib

This documentation is automatically generated by online-judge-tools/verification-helper

View on GitHub

:warning: Real solutions of quadratic equation
(Mylib/Math/quadratic_equation.cpp)

Operations

Requirements

Notes

Problems

References

Code

#pragma once
#include <cmath>
#include <vector>

namespace haar_lib {
  std::vector<double> quadratic_equation(double a, double b, double c) {
    double d = b * b - 4 * a * c;
    if (d < 0) return {};

    double x1 = (-b - std::sqrt(d)) / (2 * a);
    double x2 = (-b + std::sqrt(d)) / (2 * a);
    return {x1, x2};
  }
}  // namespace haar_lib
#line 2 "Mylib/Math/quadratic_equation.cpp"
#include <cmath>
#include <vector>

namespace haar_lib {
  std::vector<double> quadratic_equation(double a, double b, double c) {
    double d = b * b - 4 * a * c;
    if (d < 0) return {};

    double x1 = (-b - std::sqrt(d)) / (2 * a);
    double x2 = (-b + std::sqrt(d)) / (2 * a);
    return {x1, x2};
  }
}  // namespace haar_lib
Back to top page