Count of ways to generate a Matrix with product of each row and column as 1 or | C ++ implementation of the above approach ; Function to return the number of possible ways ; Check if product can be - 1 ; Driver Code
#include using namespace std ; void Solve ( int N , int M ) { int temp = ( N - 1 ) * ( M - 1 ) ; int ans = pow ( 2 , temp ) ; if ( ( N + M ) % 2 != 0 ) cout << ans ; else cout << 2 * ans ; cout << endl ; } int main ( ) { int N = 3 ; int M = 3 ; Solve ( N , M ) ; return 0 ; }