We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
frommathimportfactorialasfacn=int(input())list=input().split()m=int(input())# total events: nCm combination formulatotal=fac(n)/(fac(m)*fac(n-m))# events when selected indices doesn't contains "a"n_dup=len(list)-list.count('a')# if selecting indices is not possible without picking'a'ifn_dup<m:result=1else:prob_bar=fac(n_dup)/(fac(m)*fac(n_dup-m))result=(total-prob_bar)/totalprint(result)
Cookie support is required to access HackerRank
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 →