-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2981.py
More file actions
41 lines (35 loc) · 848 Bytes
/
2981.py
File metadata and controls
41 lines (35 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import heapq
def maxdenom(x,y):
if x< y:
x, y = y, x
if y == 0:
return x
if x%y == 0:
return y
else:
return maxdenom(y, x%y)
import sys
n = int(sys.stdin.readline().rstrip())
numList = []
newList = []
for i in range (n):
numList.append(int(sys.stdin.readline().rstrip()))
for i in range(n):
heapq.heappush(newList,abs(numList[-i]-numList[-(i+1)]))
answer =0
while True:
if len(newList) == 1:
answer = newList[0]
break
a = maxdenom(heapq.heappop(newList),heapq.heappop(newList))
newList.append(a)
answerList = []
for i in range (1, int(answer**(1/2))+1):
if answer%i == 0:
answerList.append(i)
if ((i**2)!=answer):
answerList.append(answer//i)
answerList.sort()
for i in answerList:
if i != 1:
print(i, end=" ")