Back
Close

Quadratic Formula (Easy Integer Version)

Statement
The Quadratic Formula is a commonly used formula in math that returns the value of x when given a quadratic in the form of ax^2+bx+c = 0 (a, b, c are all integers). Given a quadratic in this manner, find the x. If you do not understand the Quadratic Formula, here is a resource: https://en.wikipedia.org/wiki/Quadratic_equation <<The Quadratic Formula is special. Given a quadratic, it has two answers!>> <<However, when the discriminant b^2-4ac is negative, it has no real number solutions.>> In the quadratic formula, there is something called a +root, and a -root. If you look at the formula, b^2 will either subtract from math.sqrt(b ** 2 - 4 * a * c), or add to math.sqrt(b ** 2 - 4 * a * c). The case where it adds is called the +root, and the case where it subtracts is called the -root.

Input description
<<Line 1:>> A single string [[s]] which is your current quadratic. (It always equals zero due to the nature of the formula)

Output description
<<Please read the Wikipedia article if you don't understand what I am talking about!>> <<Line 1:>> The first value of [[x]], where it is the [[+root]], rounded <<up>> to the nearest integer. <<Line 2:>> The second value of [[x]], where it is the [[-root]], rounded <<up>> to the nearest integer. The discriminant b^2-4ac MUST not be negative. (Read Wikipedia article) If the discriminant is negative, output "no answer". In addition, if the discriminant b^2-4ac is equal to zero, there will only be one unique root. Print that root on a <<single line>>.

Constraints
x E R, or in other words, x needs to be an element of the real number set.

Game modes

Test cases
Basic Quadratic Test
Input
1x^2+5x-4
Output
1 -5

Upside-Down Parabola Validator
Input
-4x^2-6x+7
Output
-2 1

Negitive Values Test
Input
-5x^2-10x-3
Output
-1 0

Negitive Values... Again! Validator
Input
-1x^2-4x-1
Output
-3 0

Big Parabola Test
Input
-13x^2+16x+18209
Output
-36 39

Titanic Parabola Validator
Input
-1x^2+140x+18200
Output
-81 222

Negitive Discriminant Test
Input
3x^2-1x+5
Output
no answer

Another Negitive Discriminant Validator
Input
3x^2-1x+21
Output
no answer

Zero Discriminant Test
Input
3x^2-6x+3
Output
1

Another Zero Discriminant Validator
Input
8x^2+8x+2
Output
0

Solution language

Solution

Stub generator input