Farz0l1x

Untitled

Dec 18th, 2023
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. file = open('1A.txt')
  2. A = list(map(int, file.readlines()))
  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]) % 2 == 0:
  7.             count += 1
  8. print(count)
  9.  
  10. file = open('1B.txt')
  11. A = list(map(int, file.readlines()))
  12. k = [0] * 2
  13. count = 0
  14. for i in range(len(A)):
  15.     ost = (2 - A[i] % 2) % 2
  16.     count += k[ost]
  17.     k[A[i]%2] += 1
  18. print(count)
Advertisement
Add Comment
Please, Sign In to add comment