-2
$\begingroup$

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$.

$\endgroup$
  • $\begingroup$ Is $a$ an integer number? $\endgroup$ – Berci Mar 20 at 13:22
  • $\begingroup$ Edited the question! $\endgroup$ – RaphX Mar 20 at 13:24
  • $\begingroup$ Maybe you can consider the two dimensions separately, if the stones are laid in a rectangular grid. So you can ask: What is the smallest multiple of $a$ that's $\geq n$ ? And the same for $m$ ... $\endgroup$ – Matti P. Mar 20 at 13:27
  • $\begingroup$ The problem statement says "It's allowed to cover the surface larger than the Theatre Square". So what disallows a solution with one giant square flagstone with sides $\ge \max(m,n)$ ? $\endgroup$ – gandalf61 Mar 20 at 13:50
  • $\begingroup$ For equations, please use MathJax. $\endgroup$ – dantopa Mar 21 at 0:56
3
$\begingroup$

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$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.