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

来源:互联网 发布:慢跑 摇摆 知乎 编辑:程序博客网 时间:2024/04/29 05:06
  • Dashboard 
  •  Python 
  •  Itertools 
  •  Maximize It!

    from itertools import productk, 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]) % mpossible_choices = list(product(*L))print(max([f(t) for t in possible_choices]))

  • 0 0
    原创粉丝点击