Minimum sprinklers required to water a rectangular park | C ++ program to find the minimum number sprinklers required to water 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
#include <iostream> NEW_LINE using namespace std ; typedef long long int ll ; void solve ( int N , int M ) { ll ans = ( N ) * ( M / 2 ) ; if ( M % 2 == 1 ) { ans += ( N + 1 ) / 2 ; } cout << ans << endl ; } int main ( ) { int N , M ; N = 5 ; M = 3 ; solve ( N , M ) ; }