Let's try to understand the problem in simplest way:
There is a m*n size rectangle and a*a size square given, you have to fill the rectangle using minimum number of square.
Let's understand the problem in details with sample input: m=6, n=6, a=4.
Considering the rectangle is colored red and square colored green as below.
Remember, You have to use the square straight and can not break the square. You have to cover the rectangle fully, no problem if you cover more.
Trying with 1 square:
We see the rectangle (red color) is not covered completely.
Trying with 2 square:
still not covered.
Trying with 3 square:
You can see there is 4 red units is not covered yet.
Trying with 4 square:
CIAO!!, now the red rectangle is completely covered. Thus we need minimum of 4 square of given size to cover the given rectangle fully. That's why the sample answer is 4
No comments:
Post a Comment