美文网首页
ACM周赛2.1

ACM周赛2.1

作者: 九九询 | 来源:发表于2018-12-21 22:15 被阅读0次

    A - Problem A

    CodeForces - 1A
    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

    问题简述

    铺地砖,长方形的空地,正方形的地砖,且地砖不可拆分,地砖总面积可大于空地面积,地砖边线与空地边线相平行。取所需地砖最少值。

    程序分析

    地砖总面积可略大,且地砖数为整数,可通过长方形与正方形边长的相除,求出单边覆盖所需的地砖数,两者相乘,即为所需地砖数。

    AC程序如下:

    //CodeForces - 1A 
    #include<iostream>
    using namespace std;
    int main()
    {
        long long a, b, c;
        while (cin >> a >> b>>c&&(a!=0&&b!=0&&c!=0))
        {
                long long  d = 0, e = 0;
                if (a%c == 0)
                {
                    e = a / c;
                }
                if (a%c != 0)
                {
                    e = a / c + 1;
                }
                if (b%c == 0)
                {
                    d = b / c;
                }
                if (b%c != 0)
                {
                    d = b / c + 1;
                }
                long long t = e * d;
                cout << t << endl;
        } 
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:ACM周赛2.1

          本文链接:https://www.haomeiwen.com/subject/tafbkqtx.html