Minimum sprinklers required to water a rectangular park | Java program to find minimum number sprinklers required to cover the park ; Function to find the minimum number sprinklers required to water the park . ; General requirements of sprinklers ; If M is odd then add one additional sprinklers ; Driver code
class GFG { public static int solve ( int n , int m ) { int ans = n * ( m / 2 ) ; if ( m % 2 == 1 ) { ans += ( n + 1 ) / 2 ; } return ans ; } public static void main ( String args [ ] ) { int N = 5 ; int M = 3 ; System . out . println ( solve ( N , M ) ) ; } }