Count tiles of dimensions 2 * 1 that can be placed in an M * N rectangular board that satisfies the given conditions | C ++ Program to implement the above approach ; Function to count tiles of dimensions 2 x 1 that can be placed in a grid of dimensions M * N as per given conditions ; Number of tiles required ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int numberOfTiles ( int N , int M ) { if ( N % 2 == 1 ) { return -1 ; } return ( N * 1LL * M ) / 2 ; } int main ( ) { int N = 2 , M = 4 ; cout << numberOfTiles ( N , M ) ; return 0 ; }