from random import shuffle import numpy as np # 定义模拟次数 n_simulations = 100000 # 职业队和非职业队的标记,1为职业队,0为非职业队 teams = [1] * 8 + [0] * 12 # 超过四支职业队的次数 over_four_count = 0 for _ in range(n_simulations): # 随机打乱队伍顺序 shuffle(teams) # 分成四组 groups = [teams[i:i+5] for i in range(0, 20, 5)] # 检查每组职业队的数量 if any(np.sum(group) ==4 for group in groups): over_four_count += 1 # 计算概率 probability = over_four_count / n_simulations print(f"每次抽签中职业队数量等于四支的概率约为{probability:.2%}")