You are viewing a single comment's thread. Return to all 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)))
Seems like cookies are disabled on this browser, please enable them to open this website
Iterables and Iterators
You are viewing a single comment's thread. Return to all 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)))