CF Theatre Square
Theatre Square
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 易知,n/a即为需要多少块a,每一块a都能完全用完,又知,n%a若不零,那么还需要再添加一块,若为零则不需要。
所以总的块数即为(n / a + (n % a) ? 1 : )) * (m / a + (m % a) ? 1 : 0)
#include <iostream>
#include <cstdio>
using namespace std; int main(void)
{
long long n,m,a;
long long ans; scanf("%lld%lld%lld",&n,&m,&a);
ans = (n / a + ((n % a) ? : )) * (m / a + ((m % a) ? : ));
printf("%lld\n",ans); return ;
}
最新文章
- WPF DevExpress 设置雷达图Radar样式
- RabbitMQ修改端口号和心跳时间
- E - Super Jumping! Jumping! Jumping!
- 国内外从事CV相关的企业
- WIN8 MTK驱动不能安装解决办法
- Ubuntu上安装Apache、MySql和PHP
- jsp--文本框正则表达式
- Android开发之Handler
- fatal error LINK1123:failure during conversion to COFF:file invalid or corrupt
- Hbase对hive的支持没有hdfs的好的原因 及hbase什么时候使用 及rowkey设计技巧
- 【转】CentOS 使用yum命令安装出现错误提示&rdquo;could not retrieve mirrorlist http://mirrorlist.centos.org ***&rdquo;
- Cshap 使用http发起请求.
- 九宫格问题 A*
- 【Spark2.0源码学习】-1.概述
- python_如何在循环引用中管理内存?
- kubernetes进阶(05)kubernetes的命令
- 面向对象版Tab栏切换
- struts2默认临时文件更改
- 使用html中的<;input>;标签上传多个文件(转)
- 2018.09.07 Amount of degrees(数位dp)