#K45962. Maximum Regular Polygon in a Grid
Maximum Regular Polygon in a Grid
Maximum Regular Polygon in a Grid
Given a grid of dimensions n x m, determine the maximum number of sides of a regular polygon that can be placed entirely inside the grid and the number of vertices required to form such a polygon.
For this problem, the largest regular polygon that can fit inside any grid with both dimensions at least 2 is a square (4 sides and 4 vertices). If either dimension is less than 2, then no polygon can properly fit, so the answer is 0 0.
Input Format: Two space-separated integers representing the dimensions n and m.
Output Format: Two space-separated integers: the maximum number of sides of the polygon and the number of vertices required.
Note: Use \(\LaTeX\) formatting for any formulas if needed. In this problem, the polygon condition can be expressed as: if \(n \ge 2\) and \(m \ge 2\), output \(4\) and \(4\); otherwise output \(0\) and \(0\).
inputFormat
Input consists of a single line with two space-separated integers: n and m, representing the dimensions of the grid.
outputFormat
Output two space-separated integers. The first is the maximum number of sides of a regular polygon that can fit entirely within the grid, and the second is the number of vertices required to form that polygon.## sample
5 5
4 4