302928: CF571A. Lengthening Sticks

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Lengthening Sticks

题意翻译

你有三根木棍,长度分别为$a,b,c$ (单位:厘米)。你可以选择把这些木棍加长一些长度,但是加长部分总和不能超过$l$ 厘米。现在给出$a,b,c,l$ ,求有多少种加长的方案使得加上后的$a',b',c'$ 可以围成一个面积为正的三角形(即不能退化成线段或者为不成三角形)。

题目描述

You are given three sticks with positive integer lengths of $ a,b $ , and $ c $ centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most $ l $ centimeters. In particular, it is allowed not to increase the length of any stick. Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.

输入输出格式

输入格式


The single line contains $ 4 $ integers $ a,b,c,l $ ( $ 1<=a,b,c<=3·10^{5} $ , $ 0<=l<=3·10^{5} $ ).

输出格式


Print a single integer — the number of ways to increase the sizes of the sticks by the total of at most $ l $ centimeters, so that you can make a non-degenerate triangle from it.

输入输出样例

输入样例 #1

1 1 1 2

输出样例 #1

4

输入样例 #2

1 2 3 1

输出样例 #2

2

输入样例 #3

10 2 1 7

输出样例 #3

0

说明

In the first sample test you can either not increase any stick or increase any two sticks by $ 1 $ centimeter. In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.

Input

题意翻译

你有三根木棍,长度分别为$a,b,c$ (单位:厘米)。你可以选择把这些木棍加长一些长度,但是加长部分总和不能超过$l$ 厘米。现在给出$a,b,c,l$ ,求有多少种加长的方案使得加上后的$a',b',c'$ 可以围成一个面积为正的三角形(即不能退化成线段或者为不成三角形)。

加入题单

算法标签: