Advertisement
Farz0l1x

Untitled

Dec 3rd, 2023
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. from random import randint
  2. A = [randint(1, 1000) for i in range(1000)]
  3. count = 0
  4. for i in range(len(A)):
  5.     for j in range(i + 1, len(A)):
  6.         if (A[i] + A[j]) % 127 == 0:
  7.             count += 1
  8. print(count)
  9.  
  10. k = [0] * 127
  11. n = len(A)
  12. for i in range(n):
  13.     ost = A[i] % 127
  14.     k[ost] += 1
  15. count = k[0] * (k[0] - 1) // 2
  16. for i in range(1, 64):
  17.     count += k[i] * k[127 - i]
  18. print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement