Minimum number of square tiles required to fill the rectangular floor | C ++ implementation of above approach ; Function to find the number of tiles ; if breadth is divisible by side of square ; tiles required is N / s ; one more tile required ; if length is divisible by side of square ; tiles required is M / s ; one more tile required ; Driver Code ; input length and breadth of rectangle and side of square
#include <bits/stdc++.h> NEW_LINE using namespace std ; int solve ( int M , int N , int s ) { if ( N % s == 0 ) { N = N / s ; } else { N = ( N / s ) + 1 ; } if ( M % s == 0 ) { M = M / s ; } else { M = ( M / s ) + 1 ; } return M * N ; } int main ( ) { int N = 12 , M = 13 , s = 4 ; cout << solve ( M , N , s ) ; return 0 ; }