Farz0l1x

Untitled

Dec 18th, 2023
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. file = open('4A.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]) % 5 == 0 and (A[i] + A[j]) % 2 != 0:
  7.             count += 1
  8. print(count)
  9.  
  10. file = open('4B.txt')
  11. A = list(map(int, file.readlines()))
  12. count = 0
  13. k5_0, k5_1, k0, k1 = 0, 0, 0, 0
  14. for i in range(len(A)):
  15.     if A[i] % 5 == 0 and A[i] % 2 == 0:
  16.         count += (k5_1 + k1)
  17.     if A[i] % 5 == 0 and A[i] % 2 != 0:
  18.         count += (k5_0 + k0)
  19.     if A[i] % 5 != 0 and A[i] % 2 == 0:
  20.         count +=  k5_1
  21.     if A[i] % 5 != 0 and A[i] % 2 != 0:
  22.         count += k5_1
  23.        
  24.     if A[i] % 5 == 0 and A[i] % 2 == 0:
  25.         k5_0 += 1
  26.     if A[i] % 5 == 0 and A[i] % 2 != 0:
  27.         k5_1 += 1
  28.     if A[i] % 5 != 0 and A[i] % 2 == 0:
  29.         k0 += 1
  30.     if A[i] % 5 != 0 and A[i] % 2 != 0:
  31.         k1 += 1
  32. print(count)
Advertisement
Add Comment
Please, Sign In to add comment