题目 代码

#include<bits/stdc++.h>

using namespace std;

int main(){
    int x,y,z,n,m,cnt=0;
    cin >> x >> y >> z >> n >> m;
    for (int i=0; i * x <= n && i <=m;i++)
        for (int j=0; j * y + j*x <=n && j + i <=m; j++){
            int g = (n - i * x - j * y ) * z;
            if (i + j + g == m)
                cnt++;
        }
    cout << cnt << endl;
    return 0;
}

75 Wrong Answer

2 条评论

  • @ 2023-12-10 1:21:55

    python 版本

    x, y, z, n, m = map(int, input().split())
    count = 0  # 方案数
    for i in range(m + 1):
        for j in range(m + 1 - i):
            k = m - i - j
            if i * x + j * y + k /z == n:
                count += 1
    print(count)
    
    • @ 2023-9-30 18:06:13

      @ AC Code

      # include <bits/stdc++.h>
      using namespace std;
      int main() {
          int x, y, z, n, m, ret = 0;
          cin >> x >> y >> z >> n >> m;
          for (int i = 0; i <= m; i++) {
              for (int j = 0; j <= m - i; j++) {
                  int k = m - j - i;
                  if ((i * x + j * y + k / z) == n && k % z == 0) {
                      ret++;
                  }
                  
              }
          }
          cout << ret;
          return 0;
      }
      
    • 1