2988 百鸡问题 枚举

jyssh / 2024-10-23 / 原文

#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;
}