Iterables and Iterators

  • + 0 comments

    import math

    N = int(input()) all_strs = input().split() K = int(input())

    non_a_num = len(list(filter(lambda x: x!= "a", all_strs))) if non_a_num < K: print(1) else: print(1 - (math.factorial(non_a_num)/math.factorial(non_a_num-K))/(math.factorial(N)/math.factorial(N-K)))