标签:span nbsp inf ima 个数 space std display gif
三层循环,第一层,6个物品,第二层,每个物品的个数,第三层,质量范围
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 1e3 + 10; int dp[maxn]; int w[7] = {0,1,2,3,5,10,20}; int a[7]; int ans; signed main(){ // freopen("in","r",stdin); ios::sync_with_stdio(0); for(int i = 1; i <= 6; i++) cin >> a[i]; dp[0] = 1; for(int i = 1; i <= 6; i++){ for(int j = 1; j <= a[i];j++){ for(int k = 1000; k >= 0; k--){ if(dp[k]){ dp[k + w[i]] = 1; } } } } for(int i = 1; i <= 1000; i++){ if(dp[i]) ans++; } cout << "Total=" << ans << endl; return 0; }
标签:span nbsp inf ima 个数 space std display gif
原文地址:https://www.cnblogs.com/xcfxcf/p/12811056.html