题目描述
Problem Description
The "Hundred Chickens Problem" is a famous mathematical problem from the ancient Chinese text "Zhang Qiujian's Mathematical Manual". The problem states:
"Each rooster costs 5 yuan, each hen costs 3 yuan, and every 3 chicks cost 1 yuan; now with 100 yuan, buying 100 chickens, how many solutions are there?"
Xiao Ming likes this story very much, and he decides to extend this problem and solve it using programming: If each rooster costs \( x \) yuan, each hen costs \( y \) yuan, and every \( z \) chicks cost 1 yuan; now with \( n \) yuan, buying \( m \) chickens, how many solutions are there?
Input Format
The input consists of a single line containing five integers, representing \( x \), \( y \), \( z \), \( n \), and \( m \) as described in the problem. It is guaranteed that \( 1 \le x, y, z \le 10 \) and \( 1 \le n, m \le 1000 \).
Output Format
The output should be a single line containing an integer \( C \), indicating the number of solutions.
Sample Input and Output
Sample Input #1
5 3 3 100 100
Sample Output #1
4
Sample Input #2
1 1 1 100 100
Sample Output #2
5151
Notes
Sample 1 Explanation
This is the "Hundred Chickens Problem" described in the problem. There are 4 solutions:
- 0 roosters, 25 hens, 75 chicks.
- 4 roosters, 18 hens, 78 chicks.
- 8 roosters, 11 hens, 81 chicks.
- 12 roosters, 4 hens, 84 chicks.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分