using
System;
using
System.Collections.Generic;
public
class
GFG
{
public
static
int
[,] dp =
new
int
[100,(1 << 4)];
public
static
Dictionary<
int
,
int
> primeIndex =
new
Dictionary<
int
,
int
>();
public
static
int
countSetBits(
int
n)
{
int
count = 0;
while
(n > 0)
{
count += n & 1;
n >>= 1;
}
return
count;
}
public
static
int
countOfNumbers(
int
index,
int
mask,
int
N)
{
if
(index == N + 1)
{
int
countOfPrimes = countSetBits(mask);
if
(countOfPrimes == 4)
{
return
1;
}
return
0;
}
int
val = dp[index,mask];
if
(val != -1)
{
return
val;
}
val = 0;
if
(index == 1)
{
for
(
int
digit = (N == 1 ? 0 : 1);
digit <= 9; ++digit)
{
if
(primeIndex.ContainsKey(digit))
{
int
newMask = mask | (1 << primeIndex[digit]);
val += countOfNumbers(index + 1,
newMask, N);
}
else
{
val += countOfNumbers(index + 1, mask, N);
}
}
}
else
{
for
(
int
digit = 0; digit <= 9; ++digit)
{
if
(primeIndex.ContainsKey(digit))
{
int
newMask = mask | (1 << primeIndex[digit]);
val += countOfNumbers(index + 1, newMask, N);
}
else
{
val += countOfNumbers(index + 1, mask, N);
}
}
}
return
val;
}
public
static
void
Main(String[] args)
{
for
(
int
i = 0; i < 100; i++)
{
for
(
int
j = 0; j < (1 << 4); j++)
{
dp[i,j] = -1;
}
}
primeIndex.Add(2, 0);
primeIndex.Add(3, 1);
primeIndex.Add(5, 2);
primeIndex.Add(7, 3);
int
N = 4;
Console.WriteLine(countOfNumbers(1, 0, N));
}
}