Given an integer S, the task is to find the coordinates of a triangle whose area is (S / 2).
Input: S = 4
Input: S = 15
- It is know than the area of the triangle whose coordinates are (X1, Y1), (X2, Y2) and (X3, Y3) is given by A = ((X1 * Y2) + (X2 * Y3) + (X3 * Y1) – (X1 * Y3) – (X2 * Y1) – (X3 * Y2)) / 2.
- Now fixing (X1, Y1) to (0, 0) gives A = ((X2 * Y3) – (X3 * Y2)) / 2.
- It is given that A = S / 2 which implies S = (X2 * Y3) – (X3 * Y2).
- Now fix (X2, Y2) to (109, 1) and the equation becomes S = 109 * Y3 – X3 which can be solved by taking an integer value of a variable that given the integer value for the other variable.
Below is the implementation of the above approach:
(0, 0) (1000000000, 1) (999999996, 1)
Time Complexity: O(1)
- Program to find the Type of Triangle from the given Coordinates
- Find coordinates of the triangle given midpoint of each side
- Find minimum area of rectangle with given set of coordinates
- Program to find area of a triangle
- Find the altitude and area of an isosceles triangle
- Find area of triangle if two vectors of two adjacent sides are given
- Find all sides of a right angled triangle from given hypotenuse and area | Set 1
- Find the height of a right-angled triangle whose area is X times its base
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Check if a right-angled triangle can be formed by moving any one of the coordinates
- Area of Reuleaux Triangle
- Area of Incircle of a Right Angled Triangle
- Area of a triangle inside a parallelogram
- Area of Circumcircle of a Right Angled Triangle
- Check if right triangle possible from given area and hypotenuse
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.