CF926B.Add Points
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n points on a straight line, and the i-th point among them is located at x__i. All these coordinates are distinct.
Determine the number m — the smallest number of points you should add on the line to make the distances between all neighboring points equal.
一条直线上有 n 个点,其中第 i 个点的坐标为 xi。所有这些坐标互不相同。
确定数 m —— 即需要在该直线上添加的最少的点数,使得所有相邻点之间的距离均相等。
输入格式
The first line contains a single integer n (3 ≤ n ≤ 100 000) — the number of points.
The second line contains a sequence of integers _x_1, _x_2, ..., x__n ( - 109 ≤ x__i ≤ 109) — the coordinates of the points. All these coordinates are distinct. The points can be given in an arbitrary order.
第一行包含一个整数 n(3≤n≤100000)—— 点的数量。
第二行包含一个整数序列 x1,x2,...,xn(−109≤xi≤109)—— 各点的坐标。所有坐标互不相同,且点的顺序是任意的。
输出格式
Print a single integer m — the smallest number of points you should add on the line to make the distances between all neighboring points equal.
输出一个整数 m —— 为使所有相邻点之间的距离相等,需要在直线上添加的最少的点数。
输入输出样例
输入#1
3 -5 10 5
输出#1
1
输入#2
6 100 200 400 300 600 500
输出#2
0
输入#3
4 10 9 0 -1
输出#3
8
说明/提示
In the first example you can add one point with coordinate 0.
In the second example the distances between all neighboring points are already equal, so you shouldn't add anything.
在第一个例子中,你可以添加一个坐标为 0 的点。
在第二个例子中,所有相邻点之间的距离已经相等,因此你无需添加任何点。
输入解题思路,AI测评打分。不知道怎么写?