题解-python-CodeForces 1A
2 seconds
64 megabytes
standard input
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.
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.
6 6 4
4
题目是用正方形(a*a)的瓷砖铺广场(m*n的矩形) 一定要铺满,可以有多出来的不过尽可能少。。
实质是,求上整数问题: up(a/b) = ((a + b -1) / b)
代码很短(python的特点):
n,m,a = [int(s) for s in raw_input().split()]
print ((n+a-1)/a)*((m+a-1)/a)
题解-python-CodeForces 1A的更多相关文章
- CodeForces 1A Theatre Square
A - Theatre Square Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u ...
- 【题解】Codeforces 961G Partitions
[题解]Codeforces 961G Partitions cf961G 好题啊哭了,但是如果没有不小心看了一下pdf后面一页的提示根本想不到 题意 已知\(U=\{w_i\}\),求: \[ \s ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
- 【题解】Codeforces Round #798 (Div. 2)
本篇为 Codeforces Round #798 (Div. 2) 也就是 CF1689 的题解,因本人水平比较菜,所以只有前四题 A.Lex String 题目描述 原题面 给定两个字符串 \(a ...
- 【题解】 Codeforces 662A Gambling Nim (线性基)
662A,戳我戳我 Solution: 我们先取\(ans=a[1] \bigoplus a[2] \bigoplus ... \bigoplus a[n]\),然后我们定义\(c[i]=a[i] \ ...
- 【题解】 Codeforces 919F A Game With Numbers(拓扑排序+博弈论+哈希)
懒得复制,戳我戳我 Solution: 我感觉我也说不太好,看Awson的题解吧. 说一点之前打错的地方: 连边存的是hash后的数组下标 if(ans[ num( C[a.hash()] , C[b ...
- 题解【CodeForces 910A The Way to Home】
题目大意 一只青蛙现在在一个数轴上,它现在要从点 \(1\) 跳到点 \(n\) ,它每次可以向右跳不超过 \(d\) 个单位.比如,它可以从点 \(x\) 跳到点 \(x+a\)(\(1\le a\ ...
- 【题解】 Codeforces Edu44 F.Isomorphic Strings (字符串Hash)
题面戳我 Solution 我们按照每个字母出现的位置进行\(hash\),比如我们记录\(a\)的位置:我们就可以把位置表示为\(0101000111\)这种形式,然后进行字符串\(hash\) 每 ...
- 【题解】 Codeforces Edu41 F. k-substrings (字符串Hash)
题面戳我 Solution 我们正着每次都要枚举从长到短,时间复杂度承受不了,但是我们可以发现一个规律,假设某次的答案为\(x\),那么这个字符串为\(A+X+B\)组成,无论中间的\(X\)是重叠还 ...
- codeforces 1A - math - ceil
2017-08-24 15:42:30 writer: pprp 感觉自己好菜啊,这个题都没有做的很好 题意很简单,用a * a 的地砖,将 n * m 的地板铺满,问最少需要多少个地砖? 一开始打算 ...
随机推荐
- php static 变量用法
有时候我们可能需要重复调用一个函数,里面有些变量不需要重复初始化.初始化成本比较高的,我们可以使用 static 关键字修饰,在该变量没有初始化的时候才进行初始化,初始化过的变量就不再初始化.如: f ...
- Centos6.7在VMware7.0上的hgfs文件共享
站在各大巨人的肩膀上.总结如下: 1,设置虚拟机共享 虚拟机->setting->options->Shared Folders->Always Enable mount -t ...
- K8S调度之Taints and Tolerations
Taints和Tolerations(污点和容忍) 在<K8S之节点亲和性>中,我们说到的的NodeAffinity节点亲和性,是在pod上定义的一种属性,使得Pod能够被调度到某些nod ...
- 根据Bool值挑选数组中元素
根据Bool值挑选数组中元素 觉得有用的话,欢迎一起讨论相互学习~Follow Me 使用Boolean类型的数组挑选一维数组中的值 使用一维Boolean数组选取数组中的特定元素,对应位置为True ...
- 博世传感器调试笔记(二)加速度及陀螺仪传感器BMI160
一.功能参数简介bosch Sensortec公司推出的最新BMI160惯性测量单元将最顶尖的16位3轴超低重力加速度计和超低功耗3轴陀螺仪集成于单一封装.MI160采用14管脚LGA封装,尺寸为2. ...
- AspNetPager + GridView + ASP.NET AJAX 分页无刷新实现
准备资源: AspNetPager 下载网址:http://www.webdiyer.com/download/default.aspx ASP.NET AJAX 下载网址:http://www.a ...
- 如何给自己的PHP项目制作安装程序
最近很是激动啊,现在的自己还是和当初刚刚学习程序的时候一样,虽然现在回头一看自己写过的程序,都非常的小孩子和漏洞百出,也没有太多的考虑效率和安全,但是还是每次写出了新的程序或系统,都是抱着一种马上拿着 ...
- datagrid时间插件
jquery easyui日期控件中,在页面里用JS拿到设立的日期值的方法 链接:http://blog.csdn.net/liweibin_/article/details/13509917 jqu ...
- 20165230 2017-2018-2 《Java程序设计》第6周学习总结
20165230 2017-2018-2 <Java程序设计>第6周学习总结 教材学习内容总结 第八章 常用使用类 String类常用方法 public int length() publ ...
- μC/OS-Ⅱ在C8051F060上的移植及其应用
嵌入式操作系统是嵌入式应用的基础和核心.随着应用系统的不断复杂化和系统实时性需求的不断提高,对相应软件的逻辑结构.稳定性.实时性也提出了更高的要求,以传统的前后台编程模式编制软件将更加困难,而且容易出 ...