试题 历届真题 等差数列【第十届】【省赛】【B组】
方法很简单,先排序找公差,然后用两个相邻数指除以公差-1就行了
n = int(input())
lst = input().split()
last = 0
for i in range(n):
lst[i] = int(lst[i])
lst = sorted(lst)
this = 0
x = 100000 # 公差
for i in range(n-1):
tmp = lst[i+1] - lst[i]
x = min(x,tmp)
count = n
for i in range(n-1):
if lst[i+1] == lst[i]:
continue
tmp = (lst[i+1] - lst[i])/x - 1
count = count + int(tmp)
print(count)