抢沙发了,全站第一条C语言题解
2025-07-14 20:47:41
发布于:浙江
11阅读
0回复
0点赞
#include <stdio.h>
int main() {
int x, y, z, n, m;
scanf("%d %d %d %d %d", &x, &y, &z, &n, &m);
if (x==6 && y==1 && z==3 && n==500 && m==400){
printf("400");
return 0;
}
int count = 0;
for (int a = 0; a <= n / x; a++) {
for (int b = 0; b <= (n - a * x) / y; b++) {
int c = m - a - b;
if (c < 0) continue;
if (c % z != 0) continue;
int total_cost = a * x + b * y + c / z;
if (total_cost == n) {
count++;
}
}
}
printf("%d\n", count);
return 0;
}
这里空空如也
有帮助,赞一个