Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Numbers At Most N Given Digit Set
Bookmark
Input
{3,4,5}, n=345
{1,3,5,7}, n=100
{1,4,9}, n=1000
{7}, n=8
Custom
digits
=
[3, 4, 5]
,
n
=
345
n =
345
digits = {
3,4,5
} · d=3
3
S[0]
4
S[1]
5
S[2]
n
count L-digit numbers ≤ n, then add every shorter number
0
dp[0]
0
dp[1]
0
dp[2]
0
base
dp
build numbers digit by digit, keeping them ≤ n
algo
master
.
io
Step:
Count positive integers ≤ 345 whose digits all come from {3, 4, 5} (repeats allowed).
0 / 13
Input
{3,4,5}, n=345
{1,3,5,7}, n=100
{1,4,9}, n=1000
{7}, n=8
Custom
digits
=
[3, 4, 5]
,
n
=
345
0 / 13
n =
345
digits = {
3,4,5
} · d=3
3
S[0]
4
S[1]
5
S[2]
n
count L-digit numbers ≤ n, then add every shorter number
0
dp[0]
0
dp[1]
0
dp[2]
0
base
dp
build numbers digit by digit, keeping them ≤ n
algo
master
.
io
Step:
Count positive integers ≤ 345 whose digits all come from {3, 4, 5} (repeats allowed).