CF Theatre Square
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.
InputThe input contains three positive integer numbers in the first line: n,??m and a (1?≤??n,?m,?a?≤?109).
OutputWrite the needed number of flagstones.
Sample test(s) Input 6 6 4 Output 4易知,n/a即為需要多少塊a,每一塊a都能完全用完,又知,n%a若不零,那么還需要再添加一塊,若為零則不需要。
所以總的塊數(shù)即為(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 }
?
轉(zhuǎn)載于:https://www.cnblogs.com/xz816111/p/4396858.html
總結(jié)
以上是生活随笔為你收集整理的CF Theatre Square的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。