Sum of digits of the string of length 1 is i as i is only number in that string and count of good strings of length 1 that end with i is also 1
for i in range ( DIGITS ) : NEW_LINE INDENT dp [ 1 ] [ i ] = i ; NEW_LINE cnt [ 1 ] [ i ] = 1 ; NEW_LINE DEDENT for i in range ( 2 , MAX ) : NEW_LINE INDENT for j in range ( DIGITS ) : NEW_LINE INDENT for k in range ( DIGITS ) : NEW_LINE DEDENT DEDENT