• CF Theatre Square


    Theatre Square

    time limit per test
    2 seconds
    memory limit per test
    64 megabytes
    input
    standard input
    output
    standard 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.

    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.

    Sample test(s)
    Input
    6 6 4
    Output
    4


    易知,n/a即为需要多少块a,每一块a都能完全用完,又知,n%a若不零,那么还需要再添加一块,若为零则不需要。
    所以总的块数即为(n / a + (n % a) ? 1 : )) * (m / a + (m % a) ? 1 : 0)
     1 #include <iostream>
     2 #include <cstdio>
     3 using    namespace    std;
     4 
     5 int    main(void)
     6 {
     7     long    long    n,m,a;
     8     long    long    ans;
     9 
    10     scanf("%lld%lld%lld",&n,&m,&a);
    11     ans = (n / a + ((n % a) ? 1 : 0)) * (m / a + ((m % a) ? 1 : 0));
    12     printf("%lld
    ",ans);
    13 
    14     return    0;
    15 }
  • 相关阅读:
    收藏的日历js算法 很实用
    autofac system.core 的版本问题
    and 组件ui等
    vc相关
    live传264流
    录转rtsphan
    ndk errno
    cpp all记录
    and 录音等+live等
    cmake
  • 原文地址:https://www.cnblogs.com/xz816111/p/4396858.html
Copyright © 2020-2023  润新知