zoukankan      html  css  js  c++  java
  • Codeforces 1A

    A. Theatre Square

    time limit per test
    1 second
    memory limit per test
    256 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.

    Examples
    input
    6 6 4
    output
    4

    题意:给出一个长为n,宽为m的矩形,问至少需要多少块a×a的正方形填满。

    题解:模拟。利用n,m与a的整除性求解即可。
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int n,m,a;
     4 long long ans=(long long)1;
     5 int main()
     6 {
     7     scanf("%d%d%d",&n,&m,&a);
     8     if (n%a) ans*=n/a+1;
     9     else ans*=n/a;
    10     if (m%a) ans*=m/a+1;
    11     else ans*=m/a;
    12     printf("%lld
    ",ans);
    13     return 0;
    14 }
    View Code
     
  • 相关阅读:
    0Day – 2011.01.26
    JQuery_PHP 开始新的旅途
    0Day – 2011.01.25
    0Day – 2011.02.04
    Delphi 必须的一致.
    0Day – 2011.01.28
    0Day – 2011.02.23[From B4A]
    足球 看球悲惨的回忆.
    Delphi – EurekaLog6.1.01Ent下载地址
    ubuntu 拨号
  • 原文地址:https://www.cnblogs.com/zk1431043937/p/7592276.html
Copyright © 2011-2022 走看看