codeforces1A

Theatre Square

 CodeForces - 1A 

一个城市的广场面积有 N×M平方米,过段时间,恰逢这个城市的庆典活动,主办方决定在广场上铺设一种新的地砖,这种地砖每块都是a×a平方米的。
那么问题来了,最少需要多少地砖才能铺满整个广场呢?地砖一定要把广场铺满,允许地砖面积可以超过广场,同时,铺地砖的时候地砖的边必须和广场的边是平行的。

Input

输入数据包含三个正整数n,m,a(1 ≤  n, m, a ≤ 1000000000).

Output

输出最少的地砖数量。

Sample Input

6 6 4

Sample Output

4

Hint

注意数据溢出!注意数据溢出!注意数据溢出!

sol:容易的吧

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
    ll s=0;
    bool f=0;
    char ch=' ';
    while(!isdigit(ch))
    {
        f|=(ch=='-'); ch=getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
    }
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0)
    {
        putchar('-'); x=-x;
    }
    if(x<10)
    {
        putchar(x+'0'); return;
    }
    write(x/10);
    putchar((x%10)+'0');
    return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('
')
ll n,m,a;
int main()
{
    R(n); R(m); R(a);
    Wl(((n+a-1)/a)*((m+a-1)/a));
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/gaojunonly1/p/10574835.html