# Covering a plaza with square flagstones

It all about maths I don't understand, how can I solve this exercise, someone say that is a 2 dimensional problem, but I can not figure out for myself, I already understand what to do, but I don't know why is the formula, can someone explain this exercise for a dummy? http://www.codeforces.com/contest/1/problem/A

why the solution of this problem is ((m+a-1)/a)*((n+a-1)/a)?

Help really appreciated

-
People here are generally not inclined to write you complete solutions, but they will usually answer specific questions. If you can explain clearly what you understand and precisely what you do not understand, using complete sentences and correct grammar, that will be helpful. – Nate Eldredge Dec 6 '10 at 23:35
@Nate Eldredge,@ Akhil Mathew I already edit – clauch Dec 6 '10 at 23:37

So break it into one dimensional problems. How many flagstones of length a does it take to cover a path of m meters? If you can trust a and m to be integers, m/a is correct if a divides m. Otherwise you need floor (m/a) +1. One way to combine these is floor((m+a-1)/a). Try it with some small numbers to see how it works.

For two dimensions, just multiply two one dimensional problems.

-
ok I am understanding, thanks for answering, this problems are too mathematical that sometimes I try but when I read the tutorial I say WHAT?? where do they get that formula? – clauch Dec 7 '10 at 0:02

The answer is (the area to cover) / (the area per flagstone) + (penalty for having to use whole flagstones). Note that your answer is almost equal to (m*n)/(a*a) so it looks about right.

-
but I still dont know how to get to that formula, I see that formula in a tutorial, thanks for answer – clauch Dec 6 '10 at 23:42
i guess you need to study more algebraic geometry – minel Dec 6 '10 at 23:47
I think so, I need to learn more some similar example?? – clauch Dec 6 '10 at 23:50
which formula do you not understand? your original formula? my formula with words? my simplified formula with letters? all of them? – minel Dec 6 '10 at 23:53
I dont understand how to obtain the original formula, ((m+a-1)/a)*((n+a-1)/a), how can I figure out that formula?, of course I understand your formulas – clauch Dec 6 '10 at 23:57