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.
- Apothem of a n-sided regular polygon
- Area of a n-sided regular polygon with given Radius
- Length of Diagonal of a n-sided regular polygon
- Central angle of a N sided Regular Polygon
- Angle between 3 given vertices in a 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
- Find the angle of Rotational Symmetry of an N-sided regular polygon
- Area of largest Circle inscribe in N-sided Regular polygon
- Number of occurrences of a given angle formed using 3 vertices of a n-sided regular polygon
- Check if an N-sided Polygon is possible from N given angles
- Probability that the pieces of a broken stick form a n sided polygon
- Number of cycles formed by joining vertices of n sided polygon at the center
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Position of a person diametrically opposite on a circle
- Program to find the Circumcircle of any regular polygon
- Program to find the Perimeter of a Regular Polygon
- Check whether two convex regular polygon have same center or not
- Minimum side of square embedded in Regular polygon with N sides
- Program to find the Interior and Exterior Angle of a Regular Polygon
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.