点个赞再走
2026-07-31 18:30:07
发布于:广东
5阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, z, n, m;
cin >> x >> y >> z >> n >> m;
int ans = 0;
// i: 买公鸡花的钱(步长x确保数量为整数)
for (int i = 0; i <= n; i += x) {
// j: 买母鸡花的钱,上限为剩余钱n-i(步长y确保数量为整数)
for (int j = 0; i + j <= n; j += y) {
int money_chick = n - i - j; // 买小鸡的钱
int cnt_chick = z * money_chick; // 小鸡数量:每元z只
int total = i / x + j / y + cnt_chick; // 总鸡数
if (total == m)
ans++;
}
}
cout << ans << endl;
return 0;
}
这里空空如也








有帮助,赞一个