Minimum number of points required to cover all blocks of a 2 | Java program for the above approach ; Function to find the minimum number of Points required to cover a grid ; If number of block is even ; Return the minimum points ; Driver Code ; Given size of grid ; Function Call
class GFG { static int minPoints ( int n , int m ) { int ans = 0 ; if ( ( n % 2 != 0 ) && ( m % 2 != 0 ) ) { ans = ( ( n * m ) / 2 ) + 1 ; } else { ans = ( n * m ) / 2 ; } return ans ; } public static void main ( String [ ] args ) { int N = 5 , M = 7 ; System . out . print ( minPoints ( N , M ) ) ; } }