Given two positive integers N and M which denotes the sides of the convex regular polygon where N < M, the task is to check whether polygons have the same center or not if N-sided polygon was inscribed in an M-sided polygon.
Center of Polygon: Point inside a polygon which is equidistant from each vertex of the polygon.
Input: N = 9, M = 3
Polygon of side 3 when inscribed in a polygon of side 9, then both polygons have same center.
Input: N = 10, M = 3
Polygon of side 3 when inscribed in a polygon of side 10, then both polygons don’t have same center.
Approach: The key observation in this problem is that when M % N == 0, that means the sides of N-sided polygon equally covers the sides of M-sided polygon, which means both the polygons have same center.
- Check if M is divisible by N, If yes then both the polygons have same center.
- Otherwise both polygons have the different centers.
Below is the implementation of the above approach:
- Time Complexity: O(1).
- Auxiliary Space: O(1).
- Check if the given point lies inside given N points of a Convex Polygon
- Find number of diagonals in n sided convex polygon
- Number of ways a convex polygon of n+2 sides can split into triangles by connecting vertices
- Number of cycles formed by joining vertices of n sided polygon at the center
- Apothem of a n-sided regular polygon
- Program to find the Perimeter of a Regular Polygon
- Area of a n-sided regular polygon with given Radius
- Program to find the Circumcircle of any regular polygon
- Length of Diagonal of a n-sided regular polygon
- Angle between 3 given vertices in a n-sided regular polygon
- Regular polygon using only 1s in a binary numbered circle
- Area of a n-sided regular polygon with given side length
- Side of a regular n-sided polygon circumscribed in a circle
- Determine the position of the third person on regular N sided polygon
- Program to find the Interior and Exterior Angle of a Regular Polygon
- Area of largest Circle inscribe in N-sided Regular polygon
- Find the angle of Rotational Symmetry of an N-sided regular polygon
- Minimum side of square embedded in Regular polygon with N sides
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Number of occurrences of a given angle formed using 3 vertices of a n-sided 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.