Number of ways to color boundary of each block of M * N table | Java program to count the number of ways to color boundary of each block of M * N table . ; Function to compute all way to fill the boundary of all sides of the unit square ; Count possible ways to fill all upper and left side of the rectangle M * N ; Count possible ways to fill all side of the all squares unit size ; Driver code ; Number of rows ; Number of columns
import java . util . * ; class GFG { static int CountWays ( int N , int M ) { int count = 1 ; count = ( int ) Math . pow ( 3 , M + N ) ; count *= ( int ) Math . pow ( 2 , M * N ) ; return count ; } public static void main ( String args [ ] ) { int N = 3 ; int M = 2 ; System . out . println ( CountWays ( N , M ) ) ; } }