1+ """
2+ CodeForces Problem A. - Theatre Square
3+ Link: https://codeforces.com/problemset/problem/1/A
4+
5+ Problem: A theatre square is a rectangular area that needs to be paved with square flagstones.
6+ The dimensions of the square are n x m, and the side length of each flagstone is a.
7+ The goal is to determine the minimum number of flagstones required to cover the entire area.
8+
9+ Constraints: 1 ≤ n, m, a ≤ 10^9
10+ """
11+
12+ def required_flagstones (length : int , width : int , square : int ) -> int :
13+ """
14+ This function calculates the minimum number of flagstones required to cover a rectangular area.
15+
16+ Args:
17+ length (int): Length of the theatre square
18+ width (int): Width of the theatre square
19+ square (int): Side length of each flagstone
20+
21+ Returns:
22+ int: Minimum number of flagstones required
23+
24+ Logic:
25+ - Calculate the number of flagstones needed along the length (n) and width (m) of the square.
26+ - Since flagstones cannot be cut, if there is any remainder when dividing n or m by a, we need to round up to the next whole number.
27+ - Multiply the number of flagstones needed along the length by the number needed along the width to get the total number of flagstones required.
28+ """
29+ flagstones_per_row = - (- length // square ) # Equivalent to math.ceil(length / square)
30+ flagstones_per_column = - (- width // square )
31+
32+ return flagstones_per_column * flagstones_per_row
33+
34+ def main () -> None :
35+ """Main function to handle input/output."""
36+ n , m , a = map (int , input ().split ())
37+ flagstones = required_flagstones (n , m , a )
38+ print (flagstones )
39+
40+ if __name__ == "__main__" :
41+ main ()
0 commit comments