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!
Sort by
recency
|
1125 Discussions
|
Please Login in order to post a comment
One more solution, as:-
I see the same problem... THis one for example has the result of 0 when it should be 16 ((96*96)+(4*4)) % 24) for
2 24 3 24 48 96 4 24 48 96 24
Oh well, fun getting that the work...
Any of you succeed with all the test cases for this problem? I see one of the test cases (Testcase 10) is failing for me.
Input:
6 767
2 488512261 423332742
2 625040505 443232774
1 4553600
4 92134264 617699202 124100179 337650738
2 778493847 932097163
5 489894997 496724555 693361712 935903331 518538304
Expected Output: 763
My Output: 766
I'm sure my output is corret.
Simplified input with squaring inputs and modules 767
4, 100, 287
4, 654, 685
1, 105
16, 560, 295, 64, 536
4, 417, 295
25, 712, 225, 94, 66, 121
One value from each list
100 + 4 + 1 + 536 + 4 + 121 => 766
Looks like the ouput which I got is correct.
or Did I miss something in understanding the problem statement?
People asked for an easy to understand way to solve this so I made this, hope this helps
from itertools import product A, B = map(int, input().split(" "))
appended_list = [] for i in range (1, A+1): K = list(map(int, input().split(" "))) all_list= [n for n in K if n != K[0]] appended_list.append(all_list)
V = list(product(*(appended_list)))
greatest_value = 0 for j in V: add_num = 0 for l in j:
add_num = add_num+l2
current_value = add_num%B if current_value > greatest_value: greatest_value = current_value else: greatest_value = greatest_value
print(greatest_value)