Maximize It!

Sort by

recency

|

1118 Discussions

|

  • + 0 comments

    from itertools import product

    num,num1=input().split()

    list1=[]

    for i in range(int(num)):

    k,*list_value=list(map(int,input().split()))
    
    list1.append(list_value)
    

    max_value=0

    for cury in product(*list1):

    tatal_val=sum(x**2 for x in cury)%int(num1)
    
    max_value=max(max_value,tatal_val) 
    

    print(max_value)

  • + 0 comments
    K, M = tuple(map(int, input().strip().split()))
    possible = {0}
    for i in range(K):
        count, *nums = list(map(int, input().split()))
        assert count == len(nums)
        vals = {pow(x, 2, M) for x in nums}
        possible = {(a + v) % M for a in possible for v in vals}
    print(max(possible))
    
  • + 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    k,m = map(int, input().split()) inp_list = []

    for _ in range(k): _, *nums = map(int, input().split()) inp_list.append([x * x % m for x in nums])

    curr_results = {0}

    for li in inp_list: new_results = set() for res in curr_results: for ele in li: new_results.add((res + ele) % m) curr_results = new_results print(max(curr_results))

  • + 0 comments

    from itertools import combinations, product def calc_total(tp): summ =0 for t in tp: summ += t**2 return summ

    lst = [] tmpl = [] n, m = [int(ch) for ch in input().split()]

    print((n,m))

    print(max(lst[0]))

    for i in range(n): tmpl = [int(ch) for ch in input().split()] lst.append(tmpl[1:]) smax =0 groups = list(product(*lst)) for group in groups: tmp = (calc_total(group))%m if tmp > smax: smax = tmp; print(smax)

  • + 0 comments
    from itertools import product
    K,M = map(int,input().split())
    K_lists_squared=[[int(x)**2 for x in input()[2:].split()] for _ in range(K)]
    max_val = max([(sum(t)%M) for t in product(*K_lists_squared)])
    print(max_val)