You are viewing a single comment's thread. Return to all comments →
from itertools import *
k,n=input().split() k,n=int(k), int(n)
ele=[input().split()[1:] for _ in range(k)] val=0
prod_arr=product(*ele) for num in prod_arr: res=sum(int(m)**2 for m in num)%n val=max(val, res)
print(val)
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 →
from itertools import *
k,n=input().split() k,n=int(k), int(n)
ele=[input().split()[1:] for _ in range(k)] val=0
prod_arr=product(*ele) for num in prod_arr: res=sum(int(m)**2 for m in num)%n val=max(val, res)
print(val)