Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit afaa1fc

Browse files
max added
1 parent 33aa763 commit afaa1fc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎Itertools/Maximize It!/Solution.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from itertools import product
2+
3+
k, m = map(int, input().split())
4+
5+
array = []
6+
for _ in range(k):
7+
array.append(list(map(int, input().split()))[1:])
8+
9+
result = 0
10+
for combination in product(*array):
11+
result = max(sum([x * x for x in combination]) % m, result)
12+
print(result)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /