题解 | #中彩票的的概率#
中彩票的的概率
https://www.nowcoder.com/practice/531e409e1b564cfbbb275c6a8d3a4b45
from functools import reduce nums = input().split(' ') prob = input().split(' ') bought = input().split(' ') dic = dict(zip(nums,prob)) numbers = list(map(lambda x:float(dic[x]),bought)) res = round(reduce(lambda x,y:x*y,numbers),3) # reduce可以快速的将数组内所有元素按照第一个参数的运算规则进行归一化 print(res)