Write a python Code for the following: You are given a function f(X) = X^2. You are also given K lists. The i th list consists of Ni elements. You have to pick one element from each list so that the...


Write a python Code for the following:<br>You are given a function f(X) = X^2. You are also given K lists. The i th list consists of Ni elements. You have to pick one element from each list so that the value from<br>the equation below is maximized:<br>S (F (X1) + f(X2) +.. +f{X k ))%M<br>Xi denotes the element picked from the i th list . Find the maximized value S max obtained. % denotes the modulo operator. Note that you need to take exactly one<br>element from each list, not necessanily the largest element. You add the squares of the chosen elements and perform the modulo operation. The maximum value that<br>you can obtain, will be the answer to the problem.<br>Input Format : The first line contains 2 space separated integers K and M. The next K lines each contains an integer N i, denoting the number of elements in the i th<br>list, followed by Ni space separated integers denoting the elements in the list. [1<=K<=7 1<=M<=1000 1<=N i <=7 1<=Magnitude of elements in list <= 10 9]<br>Output Format : Output a single integer denoting the value S max .<br>Sample Input :<br>3 1000<br>254<br>3789<br>55789 10<br>Sample Output : 206<br>Explanation : Picking 5 from the 1st list, 9 from the 2nd list and 10 from the 3rd list gives the maximum S value equal to (52 + 92 102)% 1000 = 206.<br>

Extracted text: Write a python Code for the following: You are given a function f(X) = X^2. You are also given K lists. The i th list consists of Ni elements. You have to pick one element from each list so that the value from the equation below is maximized: S (F (X1) + f(X2) +.. +f{X k ))%M Xi denotes the element picked from the i th list . Find the maximized value S max obtained. % denotes the modulo operator. Note that you need to take exactly one element from each list, not necessanily the largest element. You add the squares of the chosen elements and perform the modulo operation. The maximum value that you can obtain, will be the answer to the problem. Input Format : The first line contains 2 space separated integers K and M. The next K lines each contains an integer N i, denoting the number of elements in the i th list, followed by Ni space separated integers denoting the elements in the list. [1<><=7><><=1000><=n i=""><=7><=magnitude of="" elements="" in="" list=""><= 10="" 9]="" output="" format="" :="" output="" a="" single="" integer="" denoting="" the="" value="" s="" max="" .="" sample="" input="" :="" 3="" 1000="" 254="" 3789="" 55789="" 10="" sample="" output="" :="" 206="" explanation="" :="" picking="" 5="" from="" the="" 1st="" list,="" 9="" from="" the="" 2nd="" list="" and="" 10="" from="" the="" 3rd="" list="" gives="" the="" maximum="" s="" value="" equal="" to="" (52="" +="" 92="" 102)%="" 1000="">

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here