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
     
  • 相关阅读:
    Codeforces Round #419 (Div. 2)
    论蒟蒻的自我修养
    12 day 1
    Balanced Teams (USACO Jan Bronze 2014)
    一个奇怪的绘图程序
    BZOJ 1002 [ FJOI 2007 ]
    BZOJ 3540 realtime-update 解题
    准备做的题目
    代码风格与树形DP
    CH round #55 Streaming #6
  • 原文地址:https://www.cnblogs.com/zk1431043937/p/7592276.html
Copyright © 2011-2022 走看看