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. Git分支管理规范

    关于Git的一些分支管理规范... 一.分支与角色说明 Git 分支类型 master 分支(主分支) 稳定版本 develop 分支(开发分支) 最新版本 release 分支(发布分支) 发布新版 ...

  2. Git基础使用教程

    Git是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理,是目前使用范围最广的版本管理工具. 之前的博客中介绍了linux下安装Git的内容,这篇博客,简单介绍下使用Gi ...

  3. SpringBoot分布式 - SpringCloud

    一:介绍 Spring Cloud是一个基于Spring Boot实现的云应用开发工具,它为基于JVM的云应用开发中涉及的配置管理.服务发现.断路器.智能路由.微代理.控制总线.全局锁.决策竞选.分布 ...

  4. 【Java并发.3】对象的共享

    本章将介绍如何共享和发布对象,从而使他们能够安全地由多个线程同时访问.这两章合在一起就形成了构建线程安全类以及通过 java.util.concurrent 类库来构建开发并发应用程序的重要基础. 3 ...

  5. Python异常处理try except

    原文地址:https://www.cnblogs.com/init-life/p/9105546.html 异常处理try except 在Python中,异常处理,主要是try except语句,通 ...

  6. 解决CPC撰写文档报错问题“无法获取“AxforApplication”控件的窗口句柄。不支持无窗口的 ActiveX 控件”

    最近公司需要把官方CPC电子申请移植到项目中,在移植完成后,撰写文档总是出现“无法获取“AxforApplication”控件的窗口句柄.不支持无窗口的 ActiveX 控件”,另楼主头疼很久,网上寥 ...

  7. Python_数据类型的补充、集合set、深浅copy

    1.数据类型的补充 1.1 元组 当元组里面只有一个元素且没有逗号时,则该数据的数据类型与括号里面的元素相同. tu1 = ('laonanhai') tu2 = ('laonanhai') prin ...

  8. 后台管理系统之邮件开发(Java实现)

    一,功能点 后台管理系统,添加用户时.对注册的新用户邮箱发送初始密码. 二,代码实现 1.Mail实体类 public class Mail { private Set<String> r ...

  9. 虚拟机Ubuntu图形界面进入命令行快捷键

    ctrl+alt+f2 https://jingyan.baidu.com/article/03b2f78c69e5c25ea337ae40.html https://www.zabbix.com/d ...

  10. react-redux异步数据操作

    import React, { Component } from 'react'; import './App.css'; import {connect} from 'react-redux'; i ...