Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size $a \times a$.
What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.
Note: $a$, $n$ and $m$ are integers and the final answer should also be an integer.
Say that $n$ and $m$ are both $6$ and $a$ is $4$. Then the minimum no should be $4$.
We can without loss generality dub n the height of the rectangle and m the width.
The total number of flagstones is equal to the number of flagstones needed to cover the width of theatre square times the number of flagstones needed to cover the height.
The number of flagstones that are needed to cover the height is equal to the height n divided by the height of a flagstone a, but if n is not divisible by a then that number is some fraction, but we still need to cover the same area as that fraction of a flagstone does, the solution the next integer higher than $\frac{n}a$, the ceiling function.
As the same thing holds for theatre squares width m, the total number of flagstones must be
$\lceil\frac{n}a\rceil\times\lceil\frac{m}a\rceil$