CF Theatre Square

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/a即为需要多少块a,每一块a都能完全用完,又知,n%a若不零,那么还需要再添加一块,若为零则不需要。
所以总的块数即为(n / a + (n % a) ? 1 : )) * (m / a + (m % a) ? 1 : 0)
 1 #include <iostream>
 2 #include <cstdio>
 3 using    namespace    std;
 4 
 5 int    main(void)
 6 {
 7     long    long    n,m,a;
 8     long    long    ans;
 9 
10     scanf("%lld%lld%lld",&n,&m,&a);
11     ans = (n / a + ((n % a) ? 1 : 0)) * (m / a + ((m % a) ? 1 : 0));
12     printf("%lld\n",ans);
13 
14     return    0;
15 }

 

posted @ 2015-04-06 22:16  Decouple  阅读(193)  评论(0编辑  收藏  举报