题解-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 的地板铺满,问最少需要多少个地砖? 一开始打算 ...
随机推荐
- ribbion的负载均衡之端口的切换
可以说在这里被坑了很久,终于今天在大神的指导下,成功实现了负载均衡,切换不同的端口,这里来记录下,首先来看下效果图吧: 到底是怎么实现的呢?到底是如何切换的呢? 具体来讲: 几个步骤,启动服务注册中心 ...
- python学习(十八)爬虫中加入cookie
转载自:原文链接 前几篇文章介绍了urllib库基本使用和爬虫的简单应用,本文介绍如何通过post信息给网站,保存登陆后cookie,并用于请求有权限的操作.保存cookie需要用到cookiejar ...
- 转:iPhone上关于相机拍照的图片的imageOrientation的问题
用相机拍摄出来的照片含有EXIF信息,UIImage的imageOrientation属性指的就是EXIF中的orientation信息.如果我们忽略orientation信息,而直接对照片进行像素处 ...
- HTTP协议(3):HTTP1.1与HTTP1.0的区别
翻了下HTTP1.1的协议标准RFC2616,下面是看到的一些它跟HTTP1.0的差别. 1. Persistent Connection持久连接 在HTTP1.0中,每对Request/Respon ...
- jQuery精仿手机上的翻牌效果菜单
代码简介: jQuery精仿手机上的翻牌效果菜单,很平滑的动画翻牌效果,每点击一下菜单,就会翻去一下,貌似很灵敏的动作.注意:如果预览时没看到效果,请刷新一下页面,让jquery载入就行了,在实际使用 ...
- Redis(Remote Dictionary Server)入门
说说特性 存储结构:键值对支持多种数据类型,包括字符串类型,散列类型,列表类型,集合类型,有序集合类型. 内存存储与持久化:支持将内存中的数据异步写入磁盘中. 丰富的功能:支持为每个键值对设置生存时间 ...
- STL-map and multimap
定义 map<int,int> a; map<int,string> a; map<double,int> a; …… 首先要知道的一些 Map是STL的一个关联容 ...
- linux查看及设置别名,权限,生成ssh秘钥
1.alias :查看系统中所有的命令别名 2.设定别名 alias 别名='原命令' 3.删除别名 unalias 别名 4.使别名永久生效 vi ~/.bashrc 写入这个文件中即可永 ...
- Django认证系统实现的web页面
结合数据库.ajax.js.Djangoform表单和认证系统的web页面 一:数据模块 扩展了Django中的user表,增加了自定义的字段 from django.db import models ...
- 利用SSLStrip截获https协议--抓取邮箱等密码
1.SSL解析 SSL 是 Secure Socket Layer 的简称, 中文意思是安全套接字层,由 NetScape公司所开发,用以保障在 Internet 上数据传输的安全,确保数据在网络的传 ...