Find the number of rectangles of size 2 * 1 which can be placed inside a rectangle of size n * m | Java 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
public class GFG { static 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 ; } public static void main ( String args [ ] ) { int n = 3 , m = 3 ; System . out . println ( NumberOfRectangles ( n , m ) ) ; } }