1A. Theatre Square

1A. Theatre Square

1A. Theatre Square

  • time limit per test1 second
  • memory limit per test256 megabytes
  • inputstandard input
  • outputstandard output

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.

首都柏林的剧院广场呈长方形,大小为n × m米。在这座城市的周年纪念日之际,决定用方形花岗岩石板铺设广场。每块石板的大小都是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^9).

输入在第一行中包含三个正整数:n,m和a(1 ≤  N M A. ≤ 109^9).

Output

Write the needed number of flagstones.

写下所需数量的石板。

Examples
input

6 6 4

output

4

Solution

考虑n,m是否正好被a除尽,如果不能,则向上取整

数据n,m,a是109^9,需要用long long类型

Code
#include <iostream>
using namespace std;

//1A. Theatre Square
int main() {
    long long n,m = 0;//n,m:剧院广场呈长方形,大小为n × m米
    long long a = 0;//a:石板的大小都是a × a
    cin >> n >> m >> a;
    long long na,ma = 0;//na,ma:剧院广场所需要的n,m方向上的石板的数量
    if(n % a == 0){
        na = n / a;
    }else{
        na = n / a + 1;
    }
    if(m % a == 0){
        ma = m / a;
    }else{
        ma = m / a + 1;
    }
    cout << ma * na << endl;
    return 0;
}
CodeForces 文章被收录于专栏

https://codeforces.ml/

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-21 19:05
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务