Find the number of rectangles of size 2 * 1 which can be placed inside a rectangle of size n * m | CPP program to Find the number of rectangles of size 2 * 1 can be placed inside a rectangle of size n * m ; function to Find the number of rectangles of size 2 * 1 can be placed inside a rectangle of size n * m ; if n is even ; if m is even ; if both are odd ; Driver code ; function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int NumberOfRectangles ( int n , int m ) { if ( n % 2 == 0 ) return ( n / 2 ) * m ; else if ( m % 2 == 0 ) return ( m / 2 ) * n ; return ( n * m - 1 ) / 2 ; } int main ( ) { int n = 3 , m = 3 ; cout << NumberOfRectangles ( n , m ) ; return 0 ; }