• 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
     
  • 相关阅读:
    cobalt strike
    php学习
    windows免费?linux免费?赶紧过来看吧
    python实现文件加密
    python写一个能生成三种一句话木马的脚本
    hardentools
    TensorFlow实战——个性化推荐
    对比深度学习十大框架:TensorFlow 并非最好?
    YCSB性能测试工具使用(转)
    Python文件夹与文件的操作(转)
  • 原文地址:https://www.cnblogs.com/zk1431043937/p/7592276.html
Copyright © 2020-2023  润新知