#abc334b. B - Christmas Trees
B - Christmas Trees
Score : points
问题描述
在一条无限延伸的东西走向的道路上,从某一特定参考点向东米处的一个点的坐标被定义为。特别是,从该参考点向西米处的点的坐标为。
Snuke 将按照每间隔米的距离,在从坐标为的点开始的道路上设置圣诞树。换句话说,对于可以用整数表示为的所有点,他将在这些点上设置一棵圣诞树。
Takahashi 和 Aoki 分别站在坐标为和 的点上。找出在Takahashi和Aoki之间(包括他们所站的位置)将会设置多少棵圣诞树。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a road that stretches infinitely to the east and west, and the coordinate of a point located meters to the east from a certain reference point on this road is defined as . In particular, the coordinate of a point located meters to the west from the reference point is .
Snuke will set up Christmas trees at points on the road at intervals of meters, starting from a point with coordinate . In other words, he will set up a Christmas tree at each point that can be expressed as using some integer .
Takahashi and Aoki are standing at points with coordinates and , respectively. Find the number of Christmas trees that will be set up between Takahashi and Aoki (including the points where they are standing).
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of Christmas trees that will be set up between Takahashi and Aoki (including the points where they are standing).
Sample Input 1
5 3 -1 6
Sample Output 1
3
Snuke will set up Christmas trees at points with coordinates . Three of them at coordinates , , and are between Takahashi and Aoki.
Sample Input 2
-2 2 1 1
Sample Output 2
0
Sometimes, Takahashi and Aoki are standing at the same point.
Sample Input 3
-177018739841739480 2436426 -80154573737296504 585335723211047198
Sample Output 3
273142010859
update @ 2024/3/10 01:20:56