Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another one is in the point x2 = 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.

Input

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.

Output

Print the minimum possible total tiredness if the friends meet in the same point.

Examples
input
3
4
output
1
input
101
99
output
2
input
5
10
output
9
找到中间数用求和公式算一下就行了
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define eps 0.00000001
#define pn printf("\n")
using namespace std;
typedef long long ll; const int maxn = 1e5+; int main()
{
int a,b;
scanf("%d%d",&a,&b);
int mid = abs(a-b);
int aa = mid/ + mid%, bb = mid/;
printf("%I64d\n", 1LL*(+aa)*aa/ + 1LL*(+bb)*bb/);
}

Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)A. Friends Meeting的更多相关文章

  1. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)B. World Cup

    The last stage of Football World Cup is played using the play-off system. There are n teams left in ...

  2. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)

    A.B都是暴力搞一搞. A: #include<bits/stdc++.h> #define fi first #define se second #define mk make_pair ...

  3. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)D. Peculiar apple-tree

    In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity ...

  4. Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)C. Laboratory Work

    Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some v ...

  5. Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did you mean...【字符串枚举,暴力】

    C. Did you mean... time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  6. Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】

    B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  7. Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】

    A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  8. Codeforces Round #543 (Div. 2, based on Technocup 2019 Final Round)

    A. Technogoblet of Fire 题意:n个人分别属于m个不同的学校 每个学校的最强者能够选中 黑客要使 k个他选中的可以稳被选 所以就为这k个人伪造学校 问最小需要伪造多少个 思路:记 ...

  9. Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)

    A. Search for Pretty Integers 题目链接:http://codeforces.com/contest/872/problem/A 题目意思:题目很简单,找到一个数,组成这个 ...

随机推荐

  1. 大数据学习[16]--使用scroll实现Elasticsearch数据遍历和深度分页[转]

    题目:使用scroll实现Elasticsearch数据遍历和深度分页 作者:星爷 出处: http://lxWei.github.io/posts/%E4%BD%BF%E7%94%A8scroll% ...

  2. 0622centos下coreseek安装及使用方法

    Coreseek 中文全文检索引擎 Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索.论坛 ...

  3. oracle regexp_like介绍和例子

    oracle regexp_like介绍和例子 学习了:http://www.cnblogs.com/einyboy/archive/2012/08/01/2617606.html ORACLE中的支 ...

  4. 好纠结啊,JeeWx商业版本号和开源版本号有什么差别呢?

    好纠结啊,JeeWx商业版本号和开源版本号有什么差别呢? JeeWx开源版本号是一套基础微信开发平台.有基础的微信菜单.素材管理.微信对接等基础功能,适合于开发人员学习研究. JeeWx商业版本号是一 ...

  5. 关于IFeatureSelection的SelectFeatures方法

    近期做项目时用到IFeatureLayer as IFeatureSelection,然后使用IFeatureSelection.SelectFeatures方法.可是得到的IFeatureSelec ...

  6. suse linux通过iso文件安装gcc

    mount -t iso9660 -o loop SLES-11-SP4-DVD-x86_64-GM-DVD1.iso /media/#仅仅上述iso1即可 不需要mount iso2 mount - ...

  7. EOJ 3348 树的顺序存储结构

    前面介绍了树的链式存储结构,那么如何用顺序存储来存储一棵树呢?在顺序存储时,我们除了存储每个结点值外,还要存储树中结点与结点之间的逻辑关系(即双亲与孩子结点之间的关系).下面介绍树的双亲存储法. 编号 ...

  8. EOJ 3037 十六进制加法

    请编写程序实现两个十六进制整数的加法. 例如:十六进制整数 3762 和 05C3,3762+05C3 =3D25 十六进制整数 CB9 和 957,CB9+957=1610 Input 第 1 行: ...

  9. [Javascript] 轻量级的JavaScript日期处理类库xDate使用指南

    XDate是一个请谅解的JavaScript的原生Date对象的封装库,提供增强的功能解析,格式化和日期处理.使用起来就和JavaScript自己的对象和方法一样,非常简单. XDate是一个请谅解的 ...

  10. 给统计人讲Python(1)_科学计算库-Numpy

    本地代码是.ipynb格式的转换到博客上很麻烦,这里展示部分代码,了解更多可以查看我的git-hub:https://github.com/Yangami/Python-for-Statisticia ...