Sanatorium

CodeForces - 732C

Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation!

Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes how many times he had a breakfast, a dinner and a supper (thus, the card contains three integers). Vasiliy could sometimes have missed some meal, for example, he could have had a breakfast and a supper, but a dinner, or, probably, at some days he haven't been at the dining room at all.

Vasiliy doesn't remember what was the time of the day when he arrived to sanatorium (before breakfast, before dinner, before supper or after supper), and the time when he left it (before breakfast, before dinner, before supper or after supper). So he considers any of these options. After Vasiliy arrived to the sanatorium, he was there all the time until he left. Please note, that it's possible that Vasiliy left the sanatorium on the same day he arrived.

According to the notes in the card, help Vasiliy determine the minimum number of meals in the dining room that he could have missed. We shouldn't count as missed meals on the arrival day before Vasiliy's arrival and meals on the departure day after he left.

Input

The only line contains three integers bd and s (0 ≤ b, d, s ≤ 1018,  b + d + s ≥ 1) — the number of breakfasts, dinners and suppers which Vasiliy had during his vacation in the sanatorium.

Output

Print single integer — the minimum possible number of meals which Vasiliy could have missed during his vacation.

Examples

Input
3 2 1
Output
1
Input
1 0 0
Output
0
Input
1 1 1
Output
0
Input
1000000000000000000 0 1000000000000000000
Output
999999999999999999

Note

In the first sample, Vasiliy could have missed one supper, for example, in case he have arrived before breakfast, have been in the sanatorium for two days (including the day of arrival) and then have left after breakfast on the third day.

In the second sample, Vasiliy could have arrived before breakfast, have had it, and immediately have left the sanatorium, not missing any meal.

In the third sample, Vasiliy could have been in the sanatorium for one day, not missing any meal.

sol:小学奥数题,找到最多的那个,一个个减过去即可

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
ll a,b,c;
int main()
{
R(a) ;R(b); R(c);
ll Max=max(max(a,b),c),ans=;
if(a<Max) ans+=Max-a-;
if(b<Max) ans+=Max-b-;
if(c<Max) ans+=Max-c-;
Wl(ans);
return ;
}
/*
input
3 2 1
output
1 Input
1 0 0
Output
0 Input
1 1 1
Output
0 Input
1000000000000000000 0 1000000000000000000
Output
999999999999999999
*/

codeforces732C的更多相关文章

随机推荐

  1. Java多线程(六)——线程让步

    一.yield()介绍 yield()的作用是让步.它能让当前线程由“运行状态”进入到“就绪状态”,从而让其它具有相同优先级的等待线程获取执行权:但是,并不能保证在当前线程调用yield()之后,其它 ...

  2. KNN-笔记(1)

    1 - 背景 KNN:k近邻,表示基于k个最近的邻居的一种机器学习方法.该方法原理简单,构造方便.且是一个非参数化模型. KNN是一个"懒学习"方法,也就是其本身没有训练过程.只有 ...

  3. FineUI经典项目展示(2)基础管理系统(附在线演示)

    本系列<FineUI经典项目展示>文章将会集中展示一批使用FineUI(开源版).专业版.MVC版的经典项目. 如果你希望自己的FineUI项目出现在这个舞台,请到官网论坛提交申请: ht ...

  4. codeforces#687 B. Remainders Game

    题意:给出n个数,和一个数p,问你在知道 x%ai  的情况下,能不能确定x%p的值 结论:当n个数的最小公倍数是p的倍数时,可以确定 代码: #include <bits/stdc++.h&g ...

  5. Git更新本地仓库

    1.查看远程仓库git remote -v2.从远程获取最新版本到本地git fetch origin master:temp3.比较本地的仓库与远程仓库的区别git diff temp4.合并tem ...

  6. 爬虫——cookies池的搭建

    https://github.com/Python3WebSpider/cookiesPool

  7. 搭建RISC-V错误记录

    错误:riscv64-unknown-elf-gcc: Command not found 解决办法:将riscv64-unknown-elf-gcc文件拷贝到根目录的/bin目录下. 原因是make ...

  8. MySQL根据某个字段查询重复的数据

    select count(*) '个数',mobile '手机号',`name` '用户名' from users group by mobile having(count(*) > 1); = ...

  9. [官网]Linux版本历史

    This is a list of links to every changelog. https://kernelnewbies.org/LinuxVersions 总结一下 2.6.x 存在了八年 ...

  10. Docker入门了解一下(第一篇)

    最近在学docker.k8s什么的,看得脑子有点乱.从来没弄过在linux上搭建一个分布式的环境,所以对这些不太了解,还是从最简单的地方剖析吧. Docker学习传送:http://www.ityou ...