You are viewing a single comment's thread. Return to all comments →
import itertools
k,m=map(int,input().split())
el_list=[]
for i in range(k):
el_list.append(list(map(int,input().split()))[1:])
all_possibility = list(itertools.product(*el_list))
print(max([sum([j**2 for j in i])%m for i in all_possibility]))
Seems like cookies are disabled on this browser, please enable them to open this website
Maximize It!
You are viewing a single comment's thread. Return to all comments →
import itertools
k,m=map(int,input().split())
el_list=[]
for i in range(k):
all_possibility = list(itertools.product(*el_list))
print(max([sum([j**2 for j in i])%m for i in all_possibility]))