题解-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 的地板铺满,问最少需要多少个地砖? 一开始打算 ...
随机推荐
- Java入门:基础算法之获取用户输入
本部分演示如何获取用户输入.我们使用Scanner类来得到用户输入.下面的实例代码中演示了如何获取用户输入的字符串.整数和float数据.主要用到了以下方法: 1)public String next ...
- Logistic Ordinal Regression
sklearn实战-乳腺癌细胞数据挖掘(博客主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&a ...
- PHP运算符的规律
^异或的规律:只有真真和假假位假 !非 判断失误的另一名比如true是false &只要有真都为真就是真其他都是假 $$就是左边是真的就不判断了 规律是一样的 |或只有假假都为假其他都是真
- Typora 自定义主题 修改左右间距
打开偏好设置,打开主题文件夹 比如要修改night主题中的间距,编辑night.css文件,修改#write样式即可. 修改其他样式类试.
- Java并发编程原理与实战六:主线程等待子线程解决方案
本文将研究的是主线程等待所有子线程执行完成之后再继续往下执行的解决方案 public class TestThread extends Thread { public void run() { Sys ...
- javamail模拟邮箱功能--邮件回复-中级实战篇【邮件回复方法】(javamail API电子邮件实例)
引言: JavaMai下载地址l jar包:http://java.sun.com/products/javamail/downloads/index.html 此篇是紧随上篇文章而封装出来的,阅读本 ...
- 同一个IIS绑定多个Htts 站点问题
默认情况一个服务器的IIS只能绑定一个HTTPS也就是443端口 要实现多个站点对应HTTPS只能更改IIS配置 地址:C:Windowssystem32inetsrvconfigapplicatio ...
- MI-NOTE黑砖
机型:MI NOTE LTE miui7刷机老是报错,remote:partition table doesn't exist,分区表不存在,于是使用磁盘模式,也看到警告不要中途拔下来,但是不知道是 ...
- 【51nod】1766 树上的最远点对
[题意]给定n个点的树,m次求[a,b]和[c,d]中各选出一个点的最大距离.abcd是标号区间,n,m<=10^5 [算法]LCA+树的直径理论+线段树 [题解] 树的直径性质:距离树上任意点 ...
- 【转】线程间操作无效: 从不是创建控件“textBox2” 的线程访问它。
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...