304899: CF931A. Friends Meeting
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Friends Meeting
题意翻译
### 题目描述 在x-坐标轴(可以视为数轴)上有两个人,分别从$a$ 位置和$b$ 位置出发。 对于每个人,他可以往任意方向无限次地移动。当他第$i$ 次移动时,疲乏度增加$i$ 。例如,一个人第$1$ 次移动疲乏度增加$1$ ,第$2$ 次移动疲乏度增加$2$ (累计疲乏度为$3$ ),第$3$ 次移动增加$3$ (累计疲乏度为$6$ ),以此类推。 试求出这两个人在同一点相遇时疲乏度的和的最小值。 ### 输入格式 分两行输入两个整数$a$ 和$b$ 。 $1 \le a,b \le 1000$ 且 $ a\neq b$ 。 ### 输出格式 一个整数,即两人疲乏度的和的最小值。 ### 样例解释 - 样例1:显然,其中一个人移动一个步即可,则答案为$1$ 。 - 样例2:显然,两人各移动一步,到达位置$100$ 。答案为$1+1=2$ 。 - 样例3:为到达位置$8$ ,左边的人向右移动$3$ 步,疲乏度为$1+2+3=6$ ;右边的人向左移动$2$ 步,疲乏度为$1+2=3$ 。答案为$6+3=9$ 。 感谢@hiuseues 提供的翻译题目描述
Two friends are on the coordinate axis $ Ox $ in points with integer coordinates. One of them is in the point $ x_{1}=a $ , another one is in the point $ x_{2}=b $ . Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes according to the following rules: the first move increases the tiredness by $ 1 $ , the second move increases the tiredness by $ 2 $ , the third — by $ 3 $ and so on. For example, if a friend moves first to the left, then to the right (returning to the same point), and then again to the left his tiredness becomes equal to $ 1+2+3=6 $ . The friends want to meet in a integer point. Determine the minimum total tiredness they should gain, if they meet in the same point.输入输出格式
输入格式
The first line contains a single integer $ a $ ( $ 1<=a<=1000 $ ) — the initial position of the first friend. The second line contains a single integer $ b $ ( $ 1<=b<=1000 $ ) — the initial position of the second friend. It is guaranteed that $ a≠b $ .
输出格式
Print the minimum possible total tiredness if the friends meet in the same point.
输入输出样例
输入样例 #1
3
4
输出样例 #1
1
输入样例 #2
101
99
输出样例 #2
2
输入样例 #3
5
10
输出样例 #3
9