CF571A.Lengthening Sticks

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

给你三根长度分别为 aa、bb 和 cc 厘米的木棍(均为正整数)。你可以将其中某些木棍的长度增加若干厘米(增加量为正整数,不同木棍的增加量可以不同),但所有增加量之和至多为 ll 厘米。特别地,也可以不增加任何木棍的长度。

请你计算有多少种增加长度的方式,使得增加后这三根木棍能构成一个非退化三角形(即面积为正的三角形)。若两种方式中某根木棍的增加量不同,则认为它们是不同的方式。

输入格式

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

单行包含 4 个整数 aa、bb、cc、ll(1≤a,b,c≤3⋅1051 \leq a, b, c \leq 3 \cdot 10^5,0≤l≤3⋅1050 \leq l \leq 3 \cdot 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.

输出一个整数——在总共最多增加 ll 厘米长度的前提下,增加三根木棍长度的方案数,使得它们能构成一个非退化三角形。

输入输出样例

  • 输入#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.

在第一个样例测试中,你可以选择不增加任何木棍的长度,或者将任意两根木棍的长度各增加 1 厘米。

在第二个样例测试中,你可以将第一根或第二根木棍的长度增加 1 厘米。注意,由初始木棍构成的三角形是退化的,因此不满足条件。

输入解题思路,AI测评打分。不知道怎么写?

首页