Minimum sprinklers required to water a rectangular 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
function solve ( N , M ) { var ans = ( N ) * parseInt ( ( M / 2 ) ) ; if ( M % 2 == 1 ) { ans += parseInt ( ( N + 1 ) / 2 ) ; } document . write ( ans ) ; } var N , M ; N = 5 ; M = 3 ; solve ( N , M ) ;