codeforce 1A 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.
The input contains three positive integer numbers in the first line: n, m and a (1 ≤ n, m, a ≤ 109).
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的更多相关文章
- CodeForces 1A Theatre Square
A - Theatre Square Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u ...
- cf--------(div1)1A. Theatre Square
A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard in ...
- 1A Theatre Square
题目大意; 有一个广场,广场的大小是n*m, 有a*a的石砖,石砖铺广场可以比广场大,石砖不能切割.问最少需要多少个石砖. ===================================== ...
- Theatre Square
http://codeforces.com/problemset/problem/1/A Theatre Square time limit per test 2 seconds memory lim ...
- CF Theatre Square
Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard input ...
- A. Theatre Square(math)
A. Theatre Square time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Educational Codeforces Round 88 (Rated for Div. 2) B、New Theatre Square C、Mixing Water
题目链接:B.New Theatre Square 题意: 你要把所有"." 都变成"*",你可以有两个选择,第一种就是一次铺一个方块(1*1),第二种就是同一 ...
- codeforces水题100道 第一题 Codeforces Beta Round #1 A. Theatre Square (math)
题目链接:http://www.codeforces.com/problemset/problem/1/A题意:至少用多少块边长为a的方块铺满NxM的矩形区域.C++代码: #include < ...
- Codeforces Beta Round #1 A. Theatre Square
从今天開始.就要在Codeforces里有一个新的開始了,貌似任务非常重的说~~ Codeforces专题我将会记录全部通过的题目,事实上仅仅要通过的题目都是水题啊!. 题目大意: 依照要求计算须要多 ...
随机推荐
- 洛谷P3414 SAC#1 - 组合数
P3414 SAC#1 - 组合数 218通过 681提交 题目提供者ProjectWTA 标签 难度普及/提高- 时空限制1s / 128MB 提交 讨论 题解 最新讨论更多讨论 讨论区出bug ...
- mysql 查看服务器正在运行的进程
有时候遇到mysql突然很久没有响应的情况,我们就想知道背后发生了什么. 这时候我们就可以通过以下的命令来查看mysql正在处理的进程: show processlist; 这个命令可以通过navic ...
- libuv移植到android
编译环境是linux + ndk,你要先添加好NDK路径的环境变量,然后进入libuv目录执行以下两句完成编译. $ source ./android-configure $NDK gyp $ mak ...
- tomcat启动 报org.apache.catalina.LifecycleException异常
java 服务器 tomcat启动 报org.apache.catalina.LifecycleException异常 异常代码如下: [2018-05-10 04:45:08,856] Artifa ...
- HTML+css零碎小知识
1.设置了float浮动的元素和绝对定位position:absolute的元素会脱离正常的文档流.但是设置absolute的元素不会占据空间,相当于隐形了. 2.相对定位position:rel ...
- POJ 2318/2398 叉积性质
2318 2398 题意:给出n条线将一块区域分成n+1块空间,再给出m个点,询问这些点在哪个空间里. 思路:由于只要求相对位置关系,而对具体位置不关心,那么易使用叉积性质得到相对位置关系(左侧/右侧 ...
- Python学习笔记(八)sorted
摘抄自:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001431823058 ...
- Do the Untwist(模拟)
ZOJ Problem Set - 1006 Do the Untwist Time Limit: 2 Seconds Memory Limit: 65536 KB Cryptography ...
- awk是全局周期
需要折行时需要用转译符,转译回车,回车是提交命令 \ 如果你的命令中有单引号也可以 awk 支持C语言 awk '{name[$1]=name[$1]+$2} END{f ...
- Redis实战(五)CentOS 7上搭建Redis集群
高可用Redis(十二):Redis Cluster https://www.cnblogs.com/renpingsheng/p/9862485.html https://www.cnblogs.c ...