2988 百鸡问题 枚举

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+10,inf = 0x3f3f3f3f;

int main()
{
    int x,y,z,n,m;
    cin >> x >> y >> z >> n >> m;
    int sum = 0;
    for(int i = 0; i <= n / x; i++)
        for(int j = 0; j <= n / y; j++)
        {
            int k = (n - i * x - j * y) * z; //剩下的钱 * z就是买小鸡的数量
            if(i + j + k == m)
                sum++; 
        }
    cout << sum;
    return 0;
}

 

posted @ 2024-10-17 16:32  CRt0729  阅读(6)  评论(0编辑  收藏  举报