A. Theatre Square

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.

python入门之后来CF刷道水题练练手~

和tag提示的一样直接用贪心就好了,将对面积的计算问题转化为对长宽的计算问题。每条边能整除就用整除的商,不能整除就用商再加一块。这个处理可以用(n-1)/a+1*((m-1)/a+1)完成也可以用(-n/a)*(-m/b)完成(当然用上if或者写个函数啥的也不是不可以……比较没那么pythonic  XD)
输入方面即可以用map也可以用list配合for赋值。

用python写题的一个好处就是不用担心精度问题……以下均为py27

n, m, a = map(int, raw_input().split())
print ((n-1)/a + 1)*((m-1)/a + 1)
n, m, a = [int(x) for x in raw_input().split()]
print (-n / a) * (-m / a)

codeforce 1A Theatre Square的更多相关文章

  1. CodeForces 1A Theatre Square

    A - Theatre Square Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  2. cf--------(div1)1A. Theatre Square

    A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard in ...

  3. 1A Theatre Square

    题目大意; 有一个广场,广场的大小是n*m,  有a*a的石砖,石砖铺广场可以比广场大,石砖不能切割.问最少需要多少个石砖. ===================================== ...

  4. Theatre Square

    http://codeforces.com/problemset/problem/1/A Theatre Square time limit per test 2 seconds memory lim ...

  5. CF Theatre Square

    Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard input ...

  6. A. Theatre Square(math)

    A. Theatre Square time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  7. Educational Codeforces Round 88 (Rated for Div. 2) B、New Theatre Square C、Mixing Water

    题目链接:B.New Theatre Square 题意: 你要把所有"." 都变成"*",你可以有两个选择,第一种就是一次铺一个方块(1*1),第二种就是同一 ...

  8. codeforces水题100道 第一题 Codeforces Beta Round #1 A. Theatre Square (math)

    题目链接:http://www.codeforces.com/problemset/problem/1/A题意:至少用多少块边长为a的方块铺满NxM的矩形区域.C++代码: #include < ...

  9. Codeforces Beta Round #1 A. Theatre Square

    从今天開始.就要在Codeforces里有一个新的開始了,貌似任务非常重的说~~ Codeforces专题我将会记录全部通过的题目,事实上仅仅要通过的题目都是水题啊!. 题目大意: 依照要求计算须要多 ...

随机推荐

  1. Linux之Makefile20160707

    说一下LINUX下的Makefile,直接根据实际碰到的Makefile进行解读: 当make的目标为all时,-C $(KDIR) 指明跳转到内核源码目录下读取那里的Makefile:M=$(PWD ...

  2. Linux之多线程20160705

    简单介绍一下多线程的API,线程的概念类似与一个任务或者说一个函数,线程一旦被创建就会运行,具体使用方法可以在Linux下使用man 命令查看: pthread_t:线程ID pthread_attr ...

  3. Mybatis中jdbcType和javaType对应关系

    Mybatis中javaType和jdbcType对应关系 JDBC Type           Java Type CHAR                String VARCHAR       ...

  4. Codeforces 97.B Superset

    A set of points on a plane is called good, if for any two points at least one of the three condition ...

  5. 如何修改mac 电脑的hosts 文件

    mac 电脑的hosts 文件对于一般用户而言是只读的,对于系统管理员而言是可以修改的. hosts文件所在的路径是: /etc/hosts 因为需要系统管理员所以命令是: 输入密码,然后就可以修改了 ...

  6. Qt ------ 主事件循环与 QEventLoop

    1.事件循环一般用exec()函数开启.QApplicaion::exec().QMessageBox::exec()都是事件循环.其中前者又被称为主事件循环. 事件循环首先是一个无限“循环”,程序在 ...

  7. update condition 字段报错

    mysql> update tf_user_present set condition="0" where id=1;ERROR 1064 (42000): You have ...

  8. linux 时间设置

    自动校准 ntpdate -u cn.pool.ntp.org 时区 rm -f /etc/localtimeln -s /usr/share/zoneinfo/Asia/Shanghai /etc/ ...

  9. 生存分析/Weibull Distribution韦布尔分布

    sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&am ...

  10. SpringBoot (四) :thymeleaf 使用详解

    原文出处: 纯洁的微笑 在上篇文章< springboot(二):web综合开发 >中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thymeleaf的使用.thymele ...