Skip to main content

[CF#1/1/A] Theatre Square

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

Popular posts from this blog

[CF#1/1/B] Spreadsheets

Spreadsheets In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc. The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23. Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example. Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system. Input The first line of the input contains integer number n (1 ≤ n ≤ 105), the ...