You are viewing a single comment's thread. Return to all comments →
from itertools import product K,M=input().split() def fx(l1): l2=list(map(lambda x:x**2,l1)) return(sum(l2)%int(M)) lists= [ list(map(int,input().split()))[1:] for _ in range(int(K))] combos=list(product(*lists)) S_max=0 for comb in combos: value=fx(comb) if value>S_max: S_max=value print(S_max)
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 →