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.
- Prepare
- Python
- Itertools
- Maximize It!
- Discussions
Maximize It!
Maximize It!
+ 0 comments import itertools k, m = [int(i) for i in input().split()] lists = [[int(j)**2 for j in input().split()[1:]] for i in range(k)] remainders = [sum(l) % m for l in itertools.product(*lists)] print(max(remainders))
+ 0 comments K, M = map(int, input().split()) could = [0] for i in range(K): new = list(map(int, input().split()))[1:] could = [(n*n + c) % M for n in new for c in could] print(max(could))
+ 0 comments # Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import product k, m = map(int, input().split()) li = (list(map(int, input().split()))[1:] for _ in range(k)) li = product(*li) s = [sum(map(lambda x: x*x, i))%m for i in li] print(max(s))
+ 0 comments from itertools import product K, M = map(int, input().split()) S = [[int(i)**2 for i in input().split()[1:]] for k in range(K)] print(max(map(lambda x: sum(x) % M, product(*S))))
+ 0 comments from itertools import * K, M = map(int, input().split()) lists = [] for i in range(K): lists.append(list(map(lambda x: int(x)**2, input().split()[1:]))) pr = list(product(*lists)) maximum = max(map(lambda x: sum(x) % M, pr)) print(maximum)
Load more conversations
Sort 868 Discussions, By:
Please Login in order to post a comment