We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
from itertools import product
s=input().split()
q=[]
e=0
for _ in range(int(s[0])):
q.append(list(map(int,input().split())))
for i in list(product(*q)):
a=0
for o in i:
a=o*o+a
if a%int(s[1])>e:
e=a%int(s[1])
print(e)
print(e)
Cookie support is required to access HackerRank
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 product
s=input().split()
q=[]
e=0
for _ in range(int(s[0])):
q.append(list(map(int,input().split())))
for i in list(product(*q)):
a=0
for o in i:
a=o*o+a
if a%int(s[1])>e:
e=a%int(s[1]) print(e) print(e)