Calculate total count of sequences of length even_count with sum divisible by A where first digit can be zero
dp = [ [ 0 for x in range ( max_sum + 1 ) ] for y in range ( even_count ) ] NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT dp [ 0 ] [ i % A ] += 1 NEW_LINE DEDENT for i in range ( 1 , even_count ) : NEW_LINE INDENT for j in range ( 10 ) : NEW_LINE INDENT for k in range ( max_sum + 1 ) : NEW_LINE INDENT if ( dp [ i - 1 ] [ k ] > 0 ) : NEW_LINE INDENT dp [ i ] [ ( j + k ) % A ] += dp [ i - 1 ] [ k ] NEW_LINE DEDENT DEDENT DEDENT DEDENT