解题思路:
注意事项:
参考代码:
#include<bits/stdc++.h>
using namespace std;
int dp[1001] = {0};
int a[20];
int main()
{
int n, t;
cin >> n >> t;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
dp[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = t; j >= 0; j--) {
if (a[i] + j <= t) {
dp[j + a[i]] += dp[j];
}
}
}
cout << dp[t] << endl;
return 0;
}
0.0分
2 人评分
简单的a+b (C语言代码)浏览:607 |
字符串的输入输出处理 (C语言代码)浏览:1017 |
字符串比较 (C语言代码)浏览:685 |
C语言训练-8除不尽的数 (C语言代码)浏览:1402 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:596 |
简单的a+b (C语言代码)浏览:565 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:667 |
Manchester-弟弟的作业浏览:4009 |
奖学金 (C语言代码)浏览:2045 |
Hello, world! (C语言代码)浏览:735 |