#1045. [GESP 2023] 百鸡问题
[GESP 2023] 百鸡问题
Problem Description
The "Hundred Chicken Problem" originates from the famous mathematical problem in ancient China in the "Zhang Qiujian Suanjing". The general idea is: "Each rooster costs 5 yuan, each hen costs 3 yuan, and for every 3 chicks, it costs 1 yuan; now with 100 yuan, how many combinations of chickens can be bought for 100 chickens?"
Xiaoming likes this story and decides to expand the 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 Description
The input consists of one line containing five integers, which represent x, y, z, n, and m respectively. The integers satisfy the following constraints:
Output Description
The output should contain one integer C, which represents the number of valid solutions.
Example
5 3 3 100 100
4
Example Explanation
In this case, the four possible solutions are:
- 0 roosters, 25 hens, and 75 chicks;
- 4 roosters, 18 hens, and 78 chicks;
- 8 roosters, 11 hens, and 81 chicks;
- 12 roosters, 4 hens, and 84 chicks.
1 1 1 100 100
5151