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
注意范围,要开long long;
求需要的石头数量,因为a是固定的大小,并且石头可以多但不可以少,所以用m和n分别除以a,有余数再加一,用求出来的数相乘就是所需的石头数;
代码如下
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,m,a;
cin>>n>>m>>a;
long long x,y,sum=0;
if(n%a)
{
x=n/a+1;
}
else
{
x=n/a;
}
if(m%a)
{
y=m/a+1;
}
else
{
y=m/a;
}
sum=x*y;
cout<<sum<<endl;
return 0;
}