您的位置:首页 > 编程语言 > Python开发

Python HackerRank|Maximize It!(from itertools import product)

2017-03-05 18:00 676 查看
Dashboard 
 Python 
 Itertools 
 Maximize
It!

from itertools import product

k, m = list(map(int, input().split()))
L = []

for _ in range(k):
L.append(list(map(int, input().split()[1:])))

def f(choices):
return sum([x ** 2 for x in choices]) % m

possible_choices = list(product(*L))
print(max([f(t) for t in possible_choices]))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: