codeforces 1A Theatre Square

来源:互联网 发布:sql镜像服务器 编辑:程序博客网 时间:2024/05/06 19:43

Theatre Square in the capital city of Berland has a rectangular shape with the sizen × 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.

Example
Input
6 6 4
Output
4
这道题也是很简单,意思就是n*m的长方形用边长是m的小正方形去铺,最少要多少块,其实就是分成长和
宽,如果刚好匹配,就用出发,不然就多一快,最后把他们相乘
#include<iostream>using namespace std;int main(){    long long n,m,a;    while(cin>>n>>m>>a)    {        long long number,numbern,numberm;        if(n%a==0) numbern = n/a;        else numbern = n/a+1;        if(m%a==0)  numberm = m/a;        else  numberm = m/a+1;        number  = numberm*numbern;        cout<<number<<endl;    }}

就好
0 0
原创粉丝点击