1 solutions

  • 3
    @ 2024-10-19 11:36:27
    #include<bits/stdc++.h>
    using namespace std;
    const int N=20010;
    int f[N];
    int main()
    {
    	int n,V;
    	cin>>n>>V;
    	f[0]=1;										//初始化 
    	for(int i=1;i<=n;i++)						//依次枚举每个物品 
    	{
    		int v;
    		cin>>v;
    		for(int j=V;j>=v;j--)f[j]=f[j]+f[j-v];	//从大到小依次枚举虚拟背包体积 
    	}
    	cout<<f[V];
    	return 0;
     }
    
    • 1

    Information

    ID
    988
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    (None)
    # Submissions
    54
    Accepted
    15
    Uploaded By