CF44B.Cola
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well).
Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer.
All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind.
为庆祝冬季计算机学校开幕,组织者决定购买 n 升可乐。然而,商店中出现了一个意外的困难:可乐仅以 0.5 升、1 升和 2 升三种容量的瓶装形式出售。其中,容量为 0.5 升的瓶子恰好有 a 瓶,容量为 1 升的瓶子恰好有 b 瓶,容量为 2 升的瓶子恰好有 c 瓶。组织者资金充足,可以购买任意数量的可乐。真正引发激烈争论的问题是:每种容量的瓶子各应购买多少瓶?因为这一问题直接关系到可乐在参与者(以及组织者)之间的分配方案。
因此,在组织者就不同购瓶方案激烈争论的同时,冬季学校却迟迟无法开始。你的任务是计算出恰好购买 n 升可乐的所有可能方案数,并说服组织者:该方案数过于庞大;若他们继续争论下去,冬季计算机学校恐怕将不得不改在夏季举办。
所有可乐瓶均被视为不可区分的,即:两种购瓶方案仅当至少某一种容量的瓶子数量不同时,才被视为不同方案。
输入格式
The first line contains four integers — n, a, b, c (1 ≤ n ≤ 10000, 0 ≤ a, b, c ≤ 5000).
第一行包含四个整数 — n、a、b、c(1 ≤ n ≤ 10000,0 ≤ a, b, c ≤ 5000)。
输出格式
Print the unique number — the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0.
输出唯一的数字——该问题的解。如果无法恰好购买 n 升可乐,则输出 0。
输入输出样例
输入#1
10 5 5 5
输出#1
9
输入#2
3 0 0 2
输出#2
0
输入解题思路,AI测评打分。不知道怎么写?