#t47. 百鸡问题扩展

百鸡问题扩展

Generalized Hundred-Chickens Problem

Problem Description

The "Hundred Chickens" problem is a famous mathematical puzzle from the ancient Chinese book Zhang Qiujian Suanjing. In brief:

"Each rooster costs 55 yuan, each hen costs 33 yuan, and 33 chicks cost 11 yuan; now with 100100 yuan you buy 100100 chickens — how many schemes are there?"

Xiao Ming loves this story and decides to generalize it and solve it by programming: if each rooster costs xx yuan, each hen costs yy yuan, and every zz chicks cost 11 yuan; and now with nn yuan you buy mm chickens, how many schemes are there?

Input Format

The input gives one line containing five integers: xx, yy, zz, nn, mm from the problem description. It is given that 1≤x,y,z≤101 \le x, y, z \le 10 and 1≤n,m≤10001 \le n, m \le 1000.

Output Format

Output one line containing a single integer CC, the number of schemes.

Sample Input 1

5 3 3 100 100

Sample Output 1

4

Sample Input 2

1 1 1 100 100

Sample Output 2

5151

Sample Explanation

The first sample corresponds to the classic "Hundred Chickens" problem: each rooster 55 yuan, each hen 33 yuan, every 33 chicks 11 yuan, 100100 yuan total, buying 100100 chickens. There are 44 schemes:

  • 00 roosters, 2525 hens, 7575 chicks: cost $0 \times 5 + 25 \times 3 + 75 \div 3 = 0 + 75 + 25 = 100$ yuan, total 0+25+75=1000 + 25 + 75 = 100 chickens.
  • 44 roosters, 1818 hens, 7878 chicks: cost $4 \times 5 + 18 \times 3 + 78 \div 3 = 20 + 54 + 26 = 100$ yuan, total 4+18+78=1004 + 18 + 78 = 100 chickens.
  • 88 roosters, 1111 hens, 8181 chicks: cost $8 \times 5 + 11 \times 3 + 81 \div 3 = 40 + 33 + 27 = 100$ yuan, total 8+11+81=1008 + 11 + 81 = 100 chickens.
  • 1212 roosters, 44 hens, 8484 chicks: cost $12 \times 5 + 4 \times 3 + 84 \div 3 = 60 + 12 + 28 = 100$ yuan, total 12+4+84=10012 + 4 + 84 = 100 chickens.

Therefore the output is 44.

Constraints

1≤x,y,z≤101 \le x, y, z \le 10, 1≤n,m≤10001 \le n, m \le 1000.