2020蓝桥杯训练-C语言-枚举-F题

廉价感情. 提交于 2020-01-19 22:53:49

Make a triangle!

Masha has three sticks of length a, b and c

centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.

What is the minimum number of minutes she needs to spend increasing the stick’s length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle’s sides (one stick for one side) and their endpoints should be located at triangle’s vertices.

Input

The only line contains tree integers a, b and c (1≤a,b,c≤100) — the lengths of sticks Masha possesses.

Output

Print a single integer — the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.

Examples

Input

3 4 5

Output

0

Input

2 5 3

Output

1

Input

100 10 10

Output

81

Note

In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.

In the second example, Masha can’t make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2
centimeter stick by one and after that form a triangle with sides 3, 3 and 5

centimeters.

In the third example, Masha can take 33
minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.

#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>c&&a+c>b&&b+c>a)
	{
		printf("0");
	}
	else if(a+b<=c)
	{
		printf("%d",c-(a+b)+1);
	}
	else if(a+c<=b)
	{
		printf("%d",b-(a+c)+1);
	}
	else if(c+b<=a)
	{
		printf("%d",a-(c+b)+1);
	}
	return 0;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!