当前位置: 代码迷 >> 综合 >> CodeForces 1A Theatre Square(math)——Codeforces Beta Round #1
  详细解决方案

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

热度:15   发布时间:2023-12-12 10:57:12.0

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;
}
菜鸟成长记


  相关解决方案