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(1000)]
- count = 0
- for i in range(len(A)):
- for j in range(i + 8, len(A)):
- if abs(A[i] - A[j]) % 999 == 0:
- count += 1
- print(count)
- k = [0] * 999
- count = 0
- q = A[:7]
- for i in range(7, len(A)):
- x = A[i]
- ost = x % 999
- count += k[ost]
- k[q[0] % 999] += 1
- q.append(x)
- q.pop(0)
- print(count)
Advertisement
Add Comment
Please, Sign In to add comment