CF931A.Friends Meeting

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Two friends are on the coordinate axis OxOx in points with integer coordinates. One of them is in the point x1=ax_{1}=a , another one is in the point x2=bx_{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 11 , the second move increases the tiredness by 22 , the third — by 33 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=61+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 aa ( 1<=a<=10001<=a<=1000 ) — the initial position of the first friend.

The second line contains a single integer bb ( 1<=b<=10001<=b<=1000 ) — the initial position of the second friend.

It is guaranteed that aba≠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
    

说明/提示

In the first example the first friend should move by one to the right (then the meeting happens at point 44 ), or the second friend should move by one to the left (then the meeting happens at point 33 ). In both cases, the total tiredness becomes 11 .

In the second example the first friend should move by one to the left, and the second friend should move by one to the right. Then they meet in the point 100100 , and the total tiredness becomes 1+1=21+1=2 .

In the third example one of the optimal ways is the following. The first friend should move three times to the right, and the second friend — two times to the left. Thus the friends meet in the point 88 , and the total tiredness becomes 1+2+3+1+2=91+2+3+1+2=9 .

首页