Theatre square Codeforces solution || Codeforces theatre square solution

## Theatre square Solution in C, CPP, Python

#### Question

Cover a square with tiles — Codeforces Problem “Theatre Square” We are given a square of size n x m the square has side large cells, and we can place only square tiles on it also each tile will have an equal number of sides.as requirement you need to find minimum numbers for covering the entire area.

The way we can solve this is to find how many tiles we need to fill the square in both dimensions separately and then multiply those numbers.

### Problem Breakdown:

Since we know that n/a = the number of tiles required to cover length n in the square; so this is just equated to statement 1. Therefore, the above complexity means ceil(n/a).

Similarly, the number of tiles needed to cover the width m can be computed by ceil(m / a).

The total tiles will be the product of these two values.

**Steps:**

use ceil(n / a) to calculate the number of tiles for length n. That’s to avoid float-ing point: ((n+a-1)//a)

Similarly, Calculate the number of tiles required to cover the width m and that would be := ceil( m+0.0/a );

The sum of the height and width is equal to the total number of tiles.

### Codeforces 1A.Theatre square Codeforces Solution in C

#include<stdio.h> int main(){ long long int a,n,m,total; scanf("%lld%lld%lld",&n,&m,&a); double hight ,width; hight=ceil((double)n/(double)a); width=ceil((double)m/(double)a);//a. theatre square solution total=hight*width; printf("%lld\n",total); return 0; }

### Codeforces 1A.Theatre square Solution in C++

#include <iostream> #include <cmath> int main() { long long int a, n, m, total; std::cin >> n >> m >> a; double hight, width; hight = ceil(static_cast<double>(n) / static_cast<double>(a)); width = ceil(static_cast<double>(m) / static_cast<double>(a)); total = hight * width; std::cout << total << std::endl; return 0; }

### Codeforces1A.Theatre squareSolution in Python

import math n, m, a = map(int, input().split()) hight = math.ceil(n / a) width = math.ceil(m / a) total = hight * width print(total)