Advertisement
Farz0l1x

Untitled

Dec 3rd, 2023
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. from random import randint
  2. A = [randint(1, 1000) for i in range(1000)]
  3. Max = -10**9
  4. for i in range(len(A)):
  5.     for j in range(i + 1, len(A)):
  6.         if (A[i] + A[j]) % 107 == 0:
  7.             Max = max(Max, A[i] + A[j])
  8. print(Max)
  9.  
  10. a = [[] for i in range(107)]
  11. n = len(A)
  12. for i in range(n):
  13.     x = A[i]
  14.     ost = x % 107
  15.     a[ost] += [x]
  16. b = []
  17. for i in range(107):
  18.     a[i].sort()
  19.     b += a[i][-2:]
  20. ans = []
  21. for i in range(len(b)):
  22.     for j in range(i + 1, len(b)):
  23.         if (b[i] + b[j]) % 107 == 0:
  24.             ans += [b[i] + b[j]]
  25. print(max(ans))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement