Codey and Rectangles
https://www.hackerrank.com/contests/codenection-2024-preliminary-round-open-category/challenges/cn24-9
Question
Codey has a rectangular sheet of paper with dimensions x
and y
. It wants to draw a rectangle that is parallel to the edges of the paper with a specified area k
. The rectangle drawn must satisfy the following conditions:
Both the width and height of the rectangle drawn must be positive integers.
The rectangle drawn must be exactly
k
square units and completely contained within the boundaries of the paper.The corners of the rectangle drawn must lie on integer coordinates.
Out of all possible rectangle dimensions with an area k
, help Codey determine the maximum number of unique positions where it can draw the rectangle of area k
on the paper.
Input Format
The first line contains three integers x
, y
, and k
, where x
and y
represent the dimensions of the rectangle sheet of paper, and k
represents the area of the rectangle drawn.
Constraints
Output Format
Output the maximum number of unique positions where the rectangle of area k
can be drawn on the paper. If there is no way the rectangle drawn will fit in paper, output .
Sample Inputs:
Input
4 4 9
Output
4
Explanation
for area , the only possible integer dimensions are:
The first dimensions would extend beyond the paper dimensions , so, it does not fit. Hence, it's optimal to have the rectangle drawn with side lengths and . It can be shown that there's 4 ways to draw a rectangle in the paper:

Last updated