hdu 6092 Rikka with Subset

哇 这题哇 我日 哇 

其实就是不断的获得物品和物品的数量 不断的更新所有物品能装满各种容量的背包的方案数 然后一剪去就好了 这样的煞笔题我们想了好一会 哇

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <limits.h>
#include <string.h>
#include <vector>
#include <map>
#include <math.h>
#define LL long long
#define INF 2100000000
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define eps 5e-7
using namespace std;
const int maxn=(int)5e4 +30;
const int MOD=998244353;
int n,m;
LL dp[maxn];
LL num[maxn];//需要LL 吗????不需要嗷 
int main(){
#ifdef shuaishuai
    freopen("C:\Users\hasee\Desktop\a.txt","r",stdin);
    //freopen("C:\Users\hasee\Desktop\b.txt","w",stdout);
#endif
    LL tmp;
    int t;
    scanf("%d",&t);
    while(t--   ){
        scanf("%d%d",&n,&m);
        scanf("%lld",&tmp);
        dp[0]=1;for(int i=1;i<=m;i++)dp[i]=0;
        int tot=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&tmp);

            int cnti=tmp-dp[i];//郝司机把它命名为 si 谁能看懂???
            //cout<<"tmp: "<<tmp<<" cnti"<<cnti<<endl;
            if(!cnti)continue;

            for(int j=0;j<cnti;j++){
                for(int k=maxn-1;k>=i;k--){
                    if(dp[k-i]) dp[k]+=dp[k-i];
                }
                num[tot++]=i;//这个数组的命名很不错 
            }
        }
        printf("%lld",num[0]);
        for(int i=1;i<tot;i++)printf(" %lld",num[i]);printf("
"); //这是最标准的输出 致郝司机的PE代码
    }
    return 0;
}
原文地址:https://www.cnblogs.com/MeowMeowMeow/p/7308503.html