Iterables and Iterators

  • + 0 comments
    from itertools import combinations
    
    n = int(input())
    s = input().split()
    k = int(input())
    
    probablity = sum('a' in t for t in combinations(s,k)) / len(tuple(combinations(s,k)))
    
    print(f'{probablity:.4f}')