Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- A = [randint(1, 1000) for i in range(100)]
- count = 0
- for i in range(len(A)):
- for j in range(i + 1, len(A)):
- if (A[i] + A[j]) % 127 == 0:
- count += 1
- print(count)
- ans = 0
- k = [0] * 127
- for i in range(len(A)):
- x = A[i]
- ost = 0 if x % 127 == 0 else 127 - x % 127
- ans += k[ost]
- k[x % 127] += 1
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment