A. Theatre Square
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard outputTheatre 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
my_list = raw_input().split()
n = int(my_list[0])
m = int(my_list[1])
a = int(my_list[2])
print (n/a+(n%a>0))*(m/a+(m%a>0)) 先十分激动的写一个Python2.7的代码~~~
当然正题是C++
这道题……我从左上开始向右向下排,刚超过为止不就行了么——
#include<stdio.h>
int main()
{
long m, n, a;
long i = 1, j = 1;
scanf("%ld %ld %ld",&m, &n, &a);
while(i * a < m)
{
i++;
}
while(j * a < n)
{
j++;
}
printf("%I64d\n", (long long)i * j);
return 0;
}

本文探讨了如何使用方砖铺设剧场广场的最小数量问题,通过输入广场尺寸和方砖尺寸,计算出所需的最少方砖数,提供了解决方案及Python代码实现。
205

被折叠的 条评论
为什么被折叠?



