A7889 | Cola
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains four integers — $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$ .
输入输出样例
输入 #1
10 5 5 5
输出 #1
9
输入 #2
3 0 0 2
输出 #2
0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted