A-Problem-A
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.
Examples
Input
6 6 4
Output
4
问题翻译:
首都柏林的剧院广场呈长方形,尺寸为N×M米。在这个城市的周年纪念日,人们决定在广场上铺上花岗岩石板。每块石板的大小都是a×A。
铺砌广场所需的石板最少是多少?它允许覆盖面积大于剧院广场的表面,但广场必须被覆盖。I它不允许打破石板。石板的侧面应该与正方形的侧面平行。
输入
输入包含第一行中的三个正整数:N,M和a(1≤N,M,a≤109)。
产出
写下需要的石板数。
例子
输入
6 6 4
产出
4
问题分析:长方形的长N和宽M分别除以石板的边长a,如果可以不可以整除,得到的结果加一,否则不加。然后两个结果相乘,即为所需的最少石板数。
C++程序代码:
#include <iostream>
using namespace std;
int main()
{
__int64 m, n, a,j,k,s;
cin >> m >> n >> a;
if (n >= 1)
{
if (m%a == 0 && n%a == 0)
{
j = m / a;
k = n / a;
s = j * k;
cout << s;
}
if (m%a == 0 && n%a != 0)
{
j = m / a;
k = n / a + 1;
s = j * k;
cout << s;
}
if (m%a != 0 && n%a == 0)
{
j = m / a + 1;
k = n / a;
s = j * k;
cout << s;
}
if (m%a != 0 && n%a != 0)
{
j = m / a + 1;
k = n / a + 1;
s = j * k;
cout << s;
}
}
}