lundi 29 juin 2015

How many small squares needed to fill a rectangle?


I am trying to solve a problem on codeforces. I am a beginner and I am just trying to understand how to solve this problem I do not want to copy someone's code.

Requirements are :

There is 1 big rectangle of nm units. (n and m are length and width). And small squares of length a are suppose to fill it up. Its okay to fill a little more are if a squares don't cover the big square (nm) completely.

If n = 6 and m = 6. area of n*m becomes 36 units. and suppose a = 4 then each tile covers 16 units of area.

Now when we lay down small squares on big rectangle it comes to 4 small squares needed to cover big rectangle.

I can easily calculate the area of large rectangle:

l_area = n * m

area of small squares :

s_area = a*a

Now how to calculate the number of small squares needed to cover the big rectangle.

The divide operator does not work for obvious reason.


Aucun commentaire:

Enregistrer un commentaire