A11649 | Add Points
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
Determine the number $m$ — the smallest number of points you should add on the line to make the distances between all neighboring points equal.
输入格式
The first line contains a single integer $n$ ( $3<=n<=100000$ ) — the number of points.
The second line contains a sequence of integers $x_{1},x_{2},...,x_{n}$ ( $-10^{9}<=x_{i}<=10^{9}$ ) — the coordinates of the points. All these coordinates are distinct. The points can be given in an arbitrary order.
The second line contains a sequence of integers $x_{1},x_{2},...,x_{n}$ ( $-10^{9}<=x_{i}<=10^{9}$ ) — the coordinates of the points. All these coordinates are distinct. The points can be given in an arbitrary order.
输出格式
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.
输入输出样例
输入 #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.
In the second example the distances between all neighboring points are already equal, so you shouldn't add anything.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted