# PROBLEM LINK:

**Author:** Puneet Gupta

**Editorialist:** Puneet Gupta

# DIFFICULTY:

CAKEWALK

# PREREQUISITES:

Math

# PROBLEM:

Given the size NxM of a rectangular shape and the size AxA of each flagstone, we have to find the least number of flagstones required to cover the shape given constraints that it is allowed to cover the surface larger than the shape, not allowed to break the flagstones and the sides of flagstones should be parallel to the sides of the Square

# EXPLANATION:

The constraint that the edges of each flagstone much be parralel to edges of the square allows you to analyze X and Y axes separately, i.e. how many segments of length ‘A’ are needed to cover segment of length ‘M’ and ‘N’ separately and you can obtain the final answer by taking the product of these two quantities.

**Answer = ceil(M/A) * ceil(N/A)**, where ceil(x) is the least integer which is above or equal to x.

Using integers only, it is usually written as **((M+A-1)/A) x ((N+A-1)/A)**.

Note that answer may be as large as 10^18, which does not fit in 32-bit integer.

Most difficulties, if any, contestants had with data types and operator priority, which are highly dependant on language used, so they are not covered here.

# AUTHOR’S SOLUTION:

Author’s solution can be found here.