// C# implementation of the approach
using System;
class GFG
{
static int maxN = 20;
static int maxM = 64;
// To store states of DP
static int [,]dp1 = new int[maxN, maxM];
static bool [,]v1 = new bool[maxN, maxM];
// Function to return the required count
static int findCnt(int []arr, int i,
int curr, int n, int m)
{
// Base case
if (i == n)
{
return (curr == m ? 1 : 0);
}
// If the state has been solved before
// return the value of the state
if (v1[i, curr])
return dp1[i, curr];
// Setting the state as solved
v1[i, curr] = true;
// Recurrence relation
dp1[i, curr] = findCnt(arr, i + 1, curr, n, m) +
findCnt(arr, i + 1, (curr & arr[i]), n, m);
return dp1[i, curr];
}
// Driver code
public static void Main(String []args)
{
int []arr = { 0, 0, 0 };
int n = arr.Length;
int m = 0;
Console.WriteLine(findCnt(arr, 0, ((1 << 6) - 1), n, m));
}
}
// This code is contributed by Rajput-Ji