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专题我将会记录全部通过的题目,事实上仅仅要通过的题目都是水题啊!. 题目大意: 依照要求计算须要多 ...
随机推荐
- Linux基础-配置网络、集群内主机名设定、ssh登入、bash命令、通配符(元字符)
作业一:临时配置网络(ip,网关,dns)+永久配置 设置临时网络配置: 配置IP ifcongfig ens33 192.168.16.177/24 (ifconfig 网卡 ip地址 /24 ...
- 【SQL优化】MySQL官网中可优化的层次结构
正如上一篇中我翻译的那篇文章,关于MySQL数据库优化的宏观介绍,了解到了从大体上来讲,优化MySQL可以从3个角度来讲.那么这一篇文章,则从一个个优化点出发,统计出究竟有多少个地方我们可以来优化My ...
- MFC之ListCtrl动态添加按钮
先上效果图: 图中用了一个CListCtrl插件,隐藏了网格线(LVS_EX_GRIDLINES). 添加了“删除”按钮(按钮上贴了图片),选中哪一行则显示在哪一行. 有两种方式创建按钮,一种是直接根 ...
- 省选模拟赛 arg
1 arg (arg.cpp/in/out, 1s, 512MB)1.1 Description给出一个长度为 m 的序列 A, 请你求出有多少种 1...n 的排列, 满足 A 是它的一个 LIS. ...
- bzoj 2530 [Poi2011]Party 构造
2530: [Poi2011]Party Time Limit: 10 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 364 Solved: ...
- MySQL查询和修改auto_increment的方法
查询表名为tableName的auto_increment值: 复制代码 代码如下: SELECT AUTO_INCREMENT FROM information_schema.tables WHER ...
- 「Django」rest_framework学习系列-用户认证
用户认证:1.项目下utils文件写auth.py文件 from rest_framework import exceptions from api import models from rest_f ...
- UVA 10479 The Hendrie Sequence
https://vjudge.net/problem/UVA-10479 打表找规律: 1.根据n可以确定第n项在上表中第i行 2.减去前i-1行,就得到了n在第i行的第j个 3.第i行的规律:1个i ...
- 字符串:KMP
KMP是字符串匹配的经典算法 也是众多字符串基础的重中之重 A. 题意:给T组数据,每组有长度为n和m的母串和模式串.判断模式串是否是母串的子串,如果是输出最先匹配完成的位置,否则输出-1. 做法:直 ...
- 配置node,sass,淘宝镜像环境
由于最近由于刚到手一台新的thinkpad(哈哈,宝宝是个小穷B,木有小苹果),所以工作开发中所用到的环境就需要重新安装一下啦,这里的话,我就把我目前所用到的进行总结一下,其余的会在以后的开发过程中, ...