for all digits we should calculate number of ways depending upon leading digits
for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 8 ; j >= 0 ; j -- ) a [ i , j ] = a [ i - 1 , j ] + a [ i , j + 1 ] ; return a [ n , 0 ] ; }