# Satisfy the parabola when point (A, B) and the equation is given

Given a point **(A, B)** such that distance from each point on the curve **M.y = N.x ^{2} + O.x + P** with

**(A, B)**is equal to the distance between that point on the curve and

**x-axis**. The task is to find the value of

**M, N O and P**.

**Note:**The equtation should be in simple form i.e.

**gcd( |M|, |N|, |O|, |P| ) = 1**and

**N**should always be positive.

**Examples:**

Input:A = 1, B = 1

Output:2 1 -2 2

M = 2, N = 1, O = -2, P = 2

The equation of the curve will be

2y = x^{2}– 2x + 2

Input:A = -1, B = 1

Output:2 1 2 2

**Approach:** From the property of the parabola, for every point on the curve the distance with the directrix and the focus will always be equal. Using this porperty, consider **y = 0** as a directrix and **(A, B)** as the focus.

Since in the equation **N** is given to be always positive, the parabola will be facing upward and the equation of the parabola is **(x – h) ^{2} = 4p(y – k)** where

**(h, k)**is the co-ordinate of the vertex and p is the distance between focus and vertex or vertex and directrix.

Since the vertex is the mid point between the perpendicular distance form focus

**(A, B)**and the directrix here (A, 0) is

**B**. So the co-ordinate of the vertex is (A, B/2) and

**p**is also

**B/2**.

So, the equation will be

**(x – A)**.

^{2}= 4 * B/2 * (y – B/2)This equation can be solved to get the result:

Below is the implementation of the above approach:

## C++

`// C++ implementation of the approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the required values ` `void` `solve(` `int` `A, ` `int` `B) ` `{ ` ` ` `double` `p = B / 2.0; ` ` ` `int` `M = ` `ceil` `(4 * p); ` ` ` `int` `N = 1; ` ` ` `int` `O = - 2 * A; ` ` ` `int` `Q = ` `ceil` `(A * A + 4 * p*p); ` ` ` `cout << M << ` `" "` `<< N << ` `" "` ` ` `<< O << ` `" "` `<< Q; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `a = 1; ` ` ` `int` `b = 1; ` ` ` `solve(a, b); ` `} ` ` ` `// This code is contributed by Mohit Kumar ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `class` `GFG ` `{ ` ` ` ` ` `// Function to find the required values ` ` ` `static` `void` `solve(` `int` `A, ` `int` `B) ` ` ` `{ ` ` ` `double` `p = B / ` `2.0` `; ` ` ` `double` `M = Math.ceil(` `4` `* p); ` ` ` `int` `N = ` `1` `; ` ` ` `int` `O = - ` `2` `* A; ` ` ` `double` `Q = Math.ceil(A * A + ` `4` `* p * p); ` ` ` `System.out.println(M + ` `" "` `+ N + ` ` ` `" "` `+ O + ` `" "` `+ Q); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main (String[] args) ` ` ` `{ ` ` ` `int` `a = ` `1` `; ` ` ` `int` `b = ` `1` `; ` ` ` `solve(a, b); ` ` ` `} ` `} ` ` ` `// This code is contributed by AnkitRai01 ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` ` ` `# Function to find the required values ` `def` `solve(A, B): ` ` ` `p ` `=` `B ` `/` `2` ` ` `M ` `=` `int` `(` `4` `*` `p) ` ` ` `N ` `=` `1` ` ` `O ` `=` `-` `2` `*` `A ` ` ` `Q ` `=` `int` `(A ` `*` `A ` `+` `4` `*` `p` `*` `p) ` ` ` `return` `[M, N, O, Q] ` ` ` `# Driver code ` `a ` `=` `1` `b ` `=` `1` `print` `(` `*` `solve(a, b)) ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find the required values ` ` ` `static` `void` `solve(` `int` `A, ` `int` `B) ` ` ` `{ ` ` ` `double` `p = B / 2.0; ` ` ` ` ` `double` `M = Math.Ceiling(4 * p); ` ` ` ` ` `int` `N = 1; ` ` ` `int` `O = - 2 * A; ` ` ` ` ` `double` `Q = Math.Ceiling(A * A + 4 * p * p); ` ` ` ` ` `Console.Write(M + ` `" "` `+ N + ` `" "` `+ O + ` `" "` `+ Q); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `static` `public` `void` `Main () ` ` ` `{ ` ` ` `int` `a = 1; ` ` ` `int` `b = 1; ` ` ` `solve(a, b); ` ` ` `} ` `} ` ` ` `// This code is contributed by AnkitRai01 ` |

*chevron_right*

*filter_none*

**Output:**

2 1 -2 2

GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details

## Recommended Posts:

- Check if a point is inside, outside or on the parabola
- Count of Fibonacci pairs which satisfy the given equation
- Number of sextuplets (or six values) that satisfy an equation
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Finding the vertex, focus and directrix of a parabola
- Reflection of a point at 180 degree rotation of another point
- Find x, y, z that satisfy 2/n = 1/x + 1/y + 1/z
- Rotation of a point about another point in C++
- Pairs from an array that satisfy the given condition
- Pair of integers (a, b) which satisfy the given equations
- Count of sub-sequences which satisfy the given condition
- Find numbers a and b that satisfy the given conditions
- Count of indices in an array that satisfy the given condition
- Find n positive integers that satisfy the given equations
- Find the minimum value of m that satisfies ax + by = m and all values after m also satisfy

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.