100871: [AtCoder]ABC087 B - Coins

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

Description

Score : $200$ points

Problem Statement

You have $A$ $500$-yen coins, $B$ $100$-yen coins and $C$ $50$-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are $X$ yen in total?

Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Constraints

  • $0 \leq A, B, C \leq 50$
  • $A + B + C \geq 1$
  • $50 \leq X \leq 20$ $000$
  • $A$, $B$ and $C$ are integers.
  • $X$ is a multiple of $50$.

Input

Input is given from Standard Input in the following format:

$A$
$B$
$C$
$X$

Output

Print the number of ways to select coins.


Sample Input 1

2
2
2
100

Sample Output 1

2

There are two ways to satisfy the condition:

  • Select zero $500$-yen coins, one $100$-yen coin and zero $50$-yen coins.
  • Select zero $500$-yen coins, zero $100$-yen coins and two $50$-yen coins.

Sample Input 2

5
1
0
150

Sample Output 2

0

Note that the total must be exactly $X$ yen.


Sample Input 3

30
40
50
6000

Sample Output 3

213

Input

题意翻译

你有500日元硬币A枚、100日元硬币B枚、50日元硬币 C枚。 现在,从这些硬币中挑出数枚硬币,各个硬币价格之和刚好等于X日元的组合有多少种。 需要注意的是: 同种类(面值)的硬币是没有区别的 不同的组合方式以某个面值的硬币数量不同来区分 0 ≤ A, B, C ≤ 50 A + B + C ≥ 1 50 ≤ X ≤ 20,000 A, B, C 一定是整数 X 一定是50的倍数 输入格式 A枚500日元硬币 B枚100日元硬币 C枚50日元硬币 组合价值之和等于X元 输出格式 组合的方式个数 感谢@linhongzhao321 提供的翻译

加入题单

上一题 下一题 算法标签: