CodeForces 1A Theatre Square(math)——Codeforces Beta Round #1

本文介绍了一个经典的算法问题——剧院广场铺设。题目要求使用特定尺寸的砖块覆盖一个矩形广场,砖块不可切割且允许超出广场边界。文章提供了解决方案,通过计算得出所需砖块的最小数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Theatre Square
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
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.

Input

The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

Output

Write the needed number of flagstones.

Sample test(s)
input
6 6 4
output
4

/*********************************************************************/

题意:一个n*m的广场,现要用a*a的砖块铺设,砖块可以超出广场的边界,但不能将砖块进行切割等操作,问至少需要多少块这样的砖才能覆盖整个广场。

解题思路:要使需要的砖块尽可能少,无疑一开始铺设砖块时砖块要挨着边界铺,这样的话,需要的砖块数


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
using namespace std;
const int N = 1001;
const int inf = 1000000000;
const int mod = 2009;
int main()
{
    __int64 n,m,a;
    scanf("%I64d%I64d%I64d",&n,&m,&a);
    printf("%I64d\n",(__int64)(ceil(1.0*n/a)*ceil(1.0*m/a)));
    return 0;
}
菜鸟成长记


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值