Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gcd(a, b):
- if b == 0:
- return a
- return gcd(b, a % b)
- n = input()
- numbers = list(map(int, input().split()))
- max_length = 1
- index_first = 0
- while index_first + max_length <= len(numbers):
- cur_g = numbers[index_first]
- length = 1
- index_second = index_first + 1
- while cur_g != 1 and index_second < len(numbers):
- cur_g = gcd(cur_g, numbers[index_second])
- numbers[index_second] //= cur_g
- length += cur_g != 1
- index_second += 1
- if length > max_length:
- max_length = length
- index_first += 1
- print(max_length)
Advertisement
Add Comment
Please, Sign In to add comment