Why my code is correct? C++

I’m trying to solve a problem in codeforces is called “Theatre Square”. According to this ,

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.

Input:

6 6 4

Output:

4

Here is my code:

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
	long long int x,y,n,m,a;
	cin >> n >> m >> a;
	x = n/a;
	y = m/a;
	if(n%a!=0){
		x++;
	}
	if(m%a!=0){
		y++;
	}
	cout << x*y << endl;
	
	return 0;	
}


According to my code ,if my input is 2 5 4 then output is 2.But it should be 3.Cus if i have 2x5 rectangular shape then i need 3 flagstones.
we
So,my code is not correct.But why it’s accepted ?

You should be able to tile with 2 tiles of 4x4 and fill a space sized 2x5.

1 Like

Always found myself dumb :roll_eyes:

It happens to all of us

1 Like