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.
输入格式
The input contains three positive integer numbers in the first line: n,m and a,范围 1e9内
输出格式
Write the needed number of flagstones.
输入输出样例
输入 #1 复制
6 6 4
输出 #1 复制
4
本题有两个坑
1: 强制类型转换
2: 分配律的应用
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
int count = 0;
ll n, m, a;
scanf("%lld %lld %lld",&n,&m,&a);
count = ll(ceil(n / (double)a) * ceil(m / (double)a));
printf("%d\n",count);
return 0;
}