You are viewing a single comment's thread. Return to all comments →
k, l = list(map(int,input().split()))
z=[]
for i in range(k): z.append(list(map(int,input().split()))[1:])
import itertools product_result = list(itertools.product(*z))
final_list=[]
def square(x): return (x**2)
for i in product_result: s=(sum(list(map(square,i)))) % l final_list.append(s)
print(max(final_list))
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 →
k, l = list(map(int,input().split()))
z=[]
for i in range(k): z.append(list(map(int,input().split()))[1:])
import itertools product_result = list(itertools.product(*z))
final_list=[]
def square(x): return (x**2)
for i in product_result: s=(sum(list(map(square,i)))) % l final_list.append(s)
print(max(final_list))