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.
The input contains three positive integer numbers in the first line: n, m and a (1 ≤ n, m, a ≤ 109).
Write the needed number of flagstones.
6 6 4
4
题意:n*m的矩形广场,石砖是a*a大小,不能弄碎石砖,覆盖面积超过广场,边缘平行广场,问要多少块砖
题解:看长和宽能不能整除,不能就加一块,两个相乘,注意要用long long ;
#include<iostream> using namespace std; typedef long long ll; int main() { ll n,m,a; cin>>n>>m>>a; ll cnt=0; ll n1=n/a; if(n%a!=0)n1++; int n2=m/a; if(m%a!=0)n2++; cout<<n1*n2; return 0; }
codeforces.com/problemset/problem/1/A
原文:https://www.cnblogs.com/fakecoderLi/p/10829055.html