2 条题解

  • 0
    @ 2026-3-27 15:59:42
    #include <bits/stdc++.h>
    using namespace std;
    const int N = 1e2 + 10;
    const int INF = 0x3f3f3f3f;
    const long long LLINF = 0x3f3f3f3f3f3f3f3fLL;
    int a[N], dp[N];
    int main(){
    	int n, m;
    	cin >> n >> m;
    	for(int i = 1 ; i <= n ; i++){
    		cin >> a[i];
    	}
    	dp[0] = 1;
    	for(int i = 1 ; i <= n ; i++){
    		for(int j = m ; j >= 1 ; j--){
    			if(j >= a[i]) dp[j] += dp[j - a[i]];
    		}
    	}
    	cout << dp[m] << endl;
    	return 0;
    } 
    

    信息

    ID
    189
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    递交数
    316
    已通过
    72
    上传者