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