zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    关于网页编码转换的几种方法
    java加载静态properties的方法
    js 点击 li 获取 设定的参数信息
    添加网关信息
    SQL 函数
    SQL Date函数
    SQL 视图(VIEW)
    SQL高级语法3
    SQL 约束
    SQL 创建表
  • 原文地址:https://www.cnblogs.com/xz816111/p/4396858.html
Copyright © 2011-2022 走看看