Farz0l1x

Untitled

Dec 2nd, 2023
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 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. B = list(map(int, file.readlines()))
  12. k0, k1 = 0, 0
  13. for i in range(len(B)):
  14.     if B[i] % 2 == 0:
  15.         k0 += 1
  16.     else:
  17.         k1 += 1
  18. print((k0 * (k0 - 1) // 2) + (k1 * (k1 - 1) // 2))
  19. #Проверка: в 13 и 14 строках B -> A
Advertisement
Add Comment
Please, Sign In to add comment