Codeforces Solution : Theatre Square

Here to remember:

– Theatre square is rectangular shape n X m meters
–  Each flagstone is of the size a X a

What is the least number of flagstones needed to pave the Square ?

Condition:
-Cover of  more than Theatre area will be allowed but Theatre Square need to covered.
-Flagstones will not be broken.It must be a X a
-The sides of flagstones should be parallel to the sides of the square

So algorithm/Hints:

1. Input n,m,a
2. rowside=n/a;
3. coloumnside=m/a;
4. We don’t need point value so x=ceil(rowside),y=ceil(coloumnside)
5. pave the whole square with x*y;
why n/a or m/a : we need to find out this relation using some brain storming to apply the equation in code and we need some mathematics tricks for this

code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,m,a;
    while(scanf("%lf%lf%lf",&n,&m,&a)==3)
    {
        printf("%.0lf\n",ceil(n/a)*ceil(m/a));
    }
    return 0;
}

 

 

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *