CodeForces
来源:互联网 发布:云计算都招聘什么岗位 编辑:程序博客网 时间:2024/06/18 06:32
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 b, d 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.
Example
Input
3 2 1
Output
1
Input
1 0 0
Output
0
Input
1 1 1
Output
0
Input
1000000000000000000 0 1000000000000000000
Output
999999999999999999
#include"stdio.h"bool sign;long long int mmax(long long int a,long long int b,long long int c){ sign=false; if(a==b&&b==c) return 0; else if(a>=b&&a>=c) { if(a==b||a==c) sign=true; return a; } else if(b>=a&&b>=c) { if(a==b||b==c) sign=true; return b; } else if(c>=a&&c>=b) { if(c==b||a==c) sign=true; return c; }}int main(){ long long int a,b,c; while(scanf("%lld%lld%lld",&a,&b,&c)==3) { if(!mmax(a,b,c)) { printf("0\n"); } else { long long int big=mmax(a,b,c); // printf("%lld",m) if(sign) printf("%lld\n",(big-1)*3-a-b-c+2); else printf("%lld\n",(big-1)*3-a-b-c+1); } } return 0;}
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 设计模式原则—开闭原则(OCP)
- 读书笔记之适配器模式
- 二叉树的后序遍历--非递归实现
- java Stringbuffer的使用
- 100003. Tree
- CodeForces
- C#中DllImport用法汇总
- hdu2852 KiKi's K-Number 线段树
- LeetCode#91. Decode Ways
- Week Training: 452 Minimum Number of Arrows to Burst Balloons
- 螺旋矩阵 II
- 客户端显示2008连接上却实2005数据库
- prophet:时间序列预测模型原理
- Shell 编程入门