Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

Given a rectangle of size **L x B**. Find the minimum number of squares required to fill the rectangle such that no two square overlaps.

**Example 1:**

**Input:** L = 4, B = 5
**Output:** 5
**Explaination:** One 4*4 square and four 1*1
squares are required.

**Example 2:**

**Input:** L = 2, B = 4
**Output:** 2
**Explaintion:** Two 2*2 squares are enough to
fill the rectangle.

**Your Task:**

You do not need to read input or print anything. Your task is to complete the function **minSquares()** which takes L and B as input parameters and returns minimum number of squares required to fill the rectangle. Return the answer modulo **10 ^{9} + 7**.

**Expected Time Complexity:** O(log(max(L, B)))

**Expected Auxiliary Space:** O(1)

Constraints:

1 ≤ L, B ≤ 10^{10}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Squares in Rectangle

...