Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
143832 | 陈家宝 | 组合总和 | C++ | 通过 | 100 | 0 MS | 264 KB | 259 | 2024-04-19 13:00:09 |
#include<bits/stdc++.h> using namespace std; int a[1000005],dp[1000005],c[1000005],n,w; int main(){ cin>>n>>w; for(int i=1;i<=n;i++)cin>>a[i]; dp[0]=1; for(int i=1;i<=w;i++)for(int j=1;j<=n;j++)dp[i]+=dp[i-a[j]]; cout<<dp[w]; return 0; }