Advertisement
Farz0l1x

Untitled

May 1st, 2024
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. file = open('2A.txt')
  2. N = int(file.readline())
  3. a = [int(x) for x in file]
  4. M = 858_967
  5. count = 0
  6. for i in range(N):
  7.     p = 1
  8.     for j in range(i, N):
  9.         p *= a[j]
  10.         if p % M != 0:
  11.             count += 1
  12.         else:
  13.             break
  14. print(count)
  15.  
  16. file = open('2B.txt')
  17. N = int(file.readline())
  18. a = [int(x) for x in file]
  19. M = 858_967
  20. count = 0
  21. p = 1
  22. l = 0
  23. for r in range(N):
  24.     p *= a[r]
  25.     while p % M == 0:
  26.         p //= a[l]
  27.         l += 1
  28.     count += r - l + 1
  29. print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement