On all n-digit numbers you need to count the number of such numbers in which any two adjacent digits have a difference modulo <= 1
Suppose there is a function f (n) = the number of these numbers
If for f (1) = 0, there are none, for f (2) there are 8 * 3 + 2 (since in the interval 10-99 there are 3 such numbers in all tens, except the number starting with 9 there are 2 of them because it is more extreme, for example 10,11,12,21,22,23,32,33,34 ... 98,99.) It turns out that f(n) = f(n-1)*10 (т.к. если к изначально подходящему числу подставить в конец любую цифру, то оно все равно удовлетворяет условию) + ..что то еще.. add f(n) = f(n-1)*10 (т.к. если к изначально подходящему числу подставить в конец любую цифру, то оно все равно удовлетворяет условию) + ..что то еще.. I can’t add this puzzle for a long time, how to count the number of the following n
|
1 answer
Fill the plate. F - the number of numbers of length N, ending with the digit L:
F(N, L) {L=1..8} = F(N-1, L-1) + F(N-1, L) + F(N-1, L+1) F(N, 0) = F(N-1, 0) + F(N-1, 1) F(N, 9) = F(N-1, 9) + F(N-1, 8) F(1, 0) = 0 F(1, K>0) = 1 - Does this mean a table like matrix N by 10? those. for each i (1 <i <= n) in 10 digits (including zero) - BogdanBida
- yes, that's right .. - mbo
|