|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
There are 68 topics, the day of the
test they will pick 5 of them randomly and she will have to choose 1 of them.
Aina wants to know how many topics she needs to study to have at least an
80% probability of passing.
本帖最后由 qq1151985918 于 2021-9-21 15:11 编辑
数学不好,结果是 19 对吗?
- def A(down, up):
- if down < up:
- raise ValueError("function A(X, Y) -> X should not be less than Y")
- multiply = 1
- for i in range(down, down-up, -1):
- multiply *= i
- return multiply
- def C(down, up):
- if down < up:
- raise ValueError("function C(X, Y) -> X should not be less than Y")
- return A(down, up) / A(up, up)
- def res(t_nums, p_nums, p):
- for i in range(1, t_nums+1):
- percent = 1 - C(t_nums-i, p_nums) / C(t_nums, p_nums)
- if percent >= p:
- return i
-
- if __name__ == "__main__":
- topic_nums = 68
- pick_nums = 5
- probability = 0.8
- print(res(topic_nums, pick_nums, probability))
复制代码
|
|