您的位置:首页 > 其它

Codeforces Round #317 (Div. 2) 571A. Lengthening Sticks 组合数学

2015-10-09 21:00 302 查看
解题报告:Codeforces
Round #317 Editorial

C. Lengthening Sticks

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

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.

Input

The single line contains 4 integers a, b, c, l (1 ≤ a, b, c ≤ 3·105, 0 ≤ l ≤ 3·105).

Output

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.

Sample test(s)

input
1 1 1 2


output
4


input
1 2 3 1


output
2


input
10 2 1 7


output
0


Note

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.

分析:数论题目 可行方案=总方案-不可行方案

C. Lengthening Sticks

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

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.

Input

The single line contains 4 integers a, b, c, l (1 ≤ a, b, c ≤ 3·105, 0 ≤ l ≤ 3·105).

Output

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.

Sample test(s)

input
1 1 1 2


output
4


input
1 2 3 1


output
2


input
10 2 1 7


output
0


Note

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.

分析:数论题目 可行方案=总方案-不可行方案
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: