Iterables and Iterators

  • + 0 comments
    from itertools import combinations 
    
    N = int(input())
    N_list = input().split()
    K = int(input())
    
    all_comb = list(combinations(N_list, K))
    length = 0
    for i in all_comb:
        if 'a' in i:
            length +=1
    probability = length / len(all_comb)
    print(round(probability, 6))