Given ‘N’ which represent the regular N sided polygon. Two children are standing on the vertex ‘A’ and ‘B’ of this Regular N sided polygon. The task is to determine the number of that vertex another person should stand on so that the sum of the minimum jumps required to reach A and minimum jumps required to reach B is minimized.
- The vertices of this regular polygon are number from 1 to N in a clockwise manner.
- If there are multiple answers, output the least numbered vertex.
Input: N = 6, A = 2, B = 4 Output: Vertex = 3 Explanation: The another person should stand on 3rd vertex. As from 3rd vertex, 1 jump is required to reach A and 1 jump is required to reach B. (See figure above) Input: N = 4, A = 1, B = 2 Output: Vertex = 3 Explanation: The another person should stand on 3rd or 4th vertex. But, as mentioned above we have to print least numbered vertex that's why the output is 3.
- Simply calculate jumps from each vertex except vertices A and B as on that vertices children are standing and store their sum in sum variable.
- Finally, print that position from where the sum of jumps is minimum.
Vertex = 3
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Polygon with maximum sides that can be inscribed in an N-sided regular polygon
- Side of a regular n-sided polygon circumscribed in a circle
- Area of a n-sided regular polygon with given side length
- Area of a n-sided regular polygon with given Radius
- Length of Diagonal of a n-sided regular polygon
- Apothem of a n-sided regular polygon
- Area of largest Circle inscribe in N-sided Regular polygon
- Angle between 3 given vertices in a n-sided regular polygon
- Number of occurrences of a given angle formed using 3 vertices of a n-sided regular polygon
- Central angle of a N sided Regular Polygon
- Find the angle of Rotational Symmetry of an N-sided regular polygon
- Number of hours after which the second person moves ahead of the first person if they travel at a given speed
- Probability that the pieces of a broken stick form a n sided polygon
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Number of cycles formed by joining vertices of n sided polygon at the center
- Check if an N-sided Polygon is possible from N given angles
- Find the vertex diagonally opposite to the vertex M from an N-sided polygon
- Position of a person diametrically opposite on a circle
- Check if given polygon is a convex polygon or not
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.