Theatre Square
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.
Solution
# ----------------------------------------------------
# I/O Utils
from math import log, sqrt
from sys import stdin, stdout
input = stdin.readline
def inint():
i = input()
return int(i)
def inlist():
i = input()
s = i.split()
l = [int(j) for j in s]
return l
def print(*out, end="\n", sep=" "):
strings = [str(o) for o in out]
stdout.write(sep.join(strings))
stdout.write(end)
return
# ----------------------------------------------------
# Math Utils
def floor(x): return int(x)
def ceil(x):
f = floor(x)
return f if f == x else f + 1
def dec2bin(x): return int(x, 2)
# ----------------------------------------------------
# Inbuilt Libs
# ----------------------------------------------------
# Boilerplate
def solve(case):
"""
What this function does?
"""
print(case)
pass
# ----------------------------------------------------
# Execution
def main():
"""
Main script starts from here
"""
# for case in range(inint()):
# solve(case)
n, m, a = inlist()
k = ceil(n / a)
j = ceil(m / a)
print(k * j)
return
if __name__ == "__main__":
main()
Comments
Post a Comment