#P8682. [蓝桥杯 2019 省 B] 等差数列

    ID: 7684 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>2019最大公约数,gcd蓝桥杯省赛

[蓝桥杯 2019 省 B] 等差数列

Description

The math teacher gave Xiao Ming a problem about summing an arithmetic progression. However, the careless Xiao Ming forgot part of the sequence and only remembers NN integers.

Now these NN integers are given. Xiao Ming wants to know: how many terms does the shortest arithmetic progression that contains all these NN integers have?

Input Format

The first line contains an integer NN.

The second line contains NN integers A1,A2,,ANA_1, A_2, \cdots, A_N (note that A1ANA_1 \sim A_N are not necessarily given in the order they appear in the arithmetic progression).

Output Format

Output one integer, the answer.

5
2 6 4 10 20
10

Hint

The shortest arithmetic progression that contains 2,6,4,10,20 is 2,4,6,8,10,12,14,16,18,20.

For all test cases, 2N1052 \le N \le 10^5, 0Ai1090 \le A_i \le 10^9.

Lanqiao Cup 2019 Provincial Contest B Group, Problem H.

Translated by ChatGPT 5