chetanrns's blog

By chetanrns, history, 7 years ago, In English

I was trying to solve 1A - Theatre Square PROBLEM STATEMENT 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 × 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. INPUT The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

OUTPUT Write the needed number of flagstones.

EXAMPLES input 6 6 4 output 4

We have to find the minimum number of flagstones that cover the rectangle.Acording to me, Area of the rectangle=n*m 1 flagstone covers the area of a*a, Since we are not allowed to break the flagstones Minimum number of flagstones that cover the entire area should be ceil( n*m / a*a),ie (total area of the rectangle)/(area covered by single flagstone) But I'm getting WA.Can someone please explain why the above method is wrong.

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it